language
stringclasses
1 value
owner
stringlengths
2
15
repo
stringlengths
2
21
sha
stringlengths
45
45
message
stringlengths
7
36.3k
path
stringlengths
1
199
patch
stringlengths
15
102k
is_multipart
bool
2 classes
Other
emberjs
ember.js
c4b3bceaf6d94a73d1c251bbacc5682474ec989c.json
point everything at the new meta module
packages/ember-runtime/lib/system/core_object.js
@@ -26,9 +26,9 @@ import { generateGuid, GUID_KEY_PROPERTY, NEXT_SUPER_PROPERTY, - meta, makeArray } from 'ember-metal/utils'; +import { meta } from 'ember-metal/meta'; import { finishChains } from 'ember-metal/chains'; import { sendEvent } from 'ember-metal/events'; import {
true
Other
emberjs
ember.js
93743c1de5324d2dc5c7ad9e82a75c9adc7ef908.json
break the meta prototype chain!
packages/ember-metal/lib/meta.js
@@ -285,17 +285,7 @@ export function meta(obj, writable) { ret.getOrCreateValues(); } } else if (ret.source !== obj) { - // temporary dance until I can eliminate remaining uses of - // prototype chain - let newRet = Object.create(ret); - newRet.parent = ret; - for (let i = 0; i < memberNames.length; i++) { - newRet[memberProperty(memberNames[i])] = undefined; - } - ret = newRet; - // end temporary dance - - ret.source = obj; + ret = new Meta(obj, ret); } obj.__ember_meta__ = ret; return ret;
false
Other
emberjs
ember.js
31c16f0fffdb1caebd8ae86c5dd05db5ef1e58b2.json
generalize upgrade support
packages/ember-metal/lib/meta.js
@@ -160,7 +160,10 @@ export function meta(obj, writable) { let newRet = Object.create(ret); newRet.parentMeta = ret; ret = newRet; - ret._cache = undefined; + for (let i = 0; i < memberNames.length; i++) { + let name = memberNames[i]; + ret['_' + name] = undefined; + } // end temporary dance ret.watching = Object.create(ret.watching);
false
Other
emberjs
ember.js
149c4f41ee5c0cfc9143b5bfcf966109ddab94f8.json
Make `isEqual` its own module.
packages/ember-runtime/lib/core.js
@@ -2,34 +2,3 @@ @module ember @submodule ember-runtime */ - -/** - Compares two objects, returning true if they are logically equal. This is - a deeper comparison than a simple triple equal. For sets it will compare the - internal objects. For any other object that implements `isEqual()` it will - respect that method. - - ```javascript - Ember.isEqual('hello', 'hello'); // true - Ember.isEqual(1, 2); // false - 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 -*/ -export 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; -}
true
Other
emberjs
ember.js
149c4f41ee5c0cfc9143b5bfcf966109ddab94f8.json
Make `isEqual` its own module.
packages/ember-runtime/lib/is-equal.js
@@ -0,0 +1,31 @@ +/** + Compares two objects, returning true if they are logically equal. This is + a deeper comparison than a simple triple equal. For sets it will compare the + internal objects. For any other object that implements `isEqual()` it will + respect that method. + + ```javascript + Ember.isEqual('hello', 'hello'); // true + Ember.isEqual(1, 2); // false + Ember.isEqual([4, 2], [4, 2]); // false + Ember.isEqual({ isEqual() { return true;} }, null) // true + ``` + + @method isEqual + @for Ember + @param {Object} a first object to compare + @param {Object} b second object to compare + @return {Boolean} + @public +*/ +export default 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; +}
true
Other
emberjs
ember.js
149c4f41ee5c0cfc9143b5bfcf966109ddab94f8.json
Make `isEqual` its own module.
packages/ember-runtime/lib/main.js
@@ -5,7 +5,7 @@ // BEGIN IMPORTS import Ember from 'ember-metal'; -import { isEqual } from 'ember-runtime/core'; +import isEqual from 'ember-runtime/is-equal'; import compare from 'ember-runtime/compare'; import copy from 'ember-runtime/copy'; import inject from 'ember-runtime/inject';
true
Other
emberjs
ember.js
149c4f41ee5c0cfc9143b5bfcf966109ddab94f8.json
Make `isEqual` its own module.
packages/ember-runtime/tests/core/isEqual_test.js
@@ -1,4 +1,4 @@ -import {isEqual} from 'ember-runtime/core'; +import isEqual from 'ember-runtime/is-equal'; QUnit.module('isEqual');
true
Other
emberjs
ember.js
91804148f5c2653fc75246d1d620993f170e73f4.json
Fix optional feature tests.
package.json
@@ -27,7 +27,7 @@ "ember-cli-sauce": "^1.3.0", "ember-cli-yuidoc": "0.7.0", "ember-publisher": "0.0.7", - "emberjs-build": "0.2.2", + "emberjs-build": "0.2.4", "express": "^4.5.0", "finalhandler": "^0.4.0", "github": "^0.2.3",
true
Other
emberjs
ember.js
91804148f5c2653fc75246d1d620993f170e73f4.json
Fix optional feature tests.
packages/ember-metal/lib/features.js
@@ -1,4 +1,6 @@ import Ember from 'ember-metal/core'; +import assign from 'ember-metal/assign'; + /** The hash of enabled Canary features. Add to this, any canary features before creating your application. @@ -12,7 +14,7 @@ import Ember from 'ember-metal/core'; @since 1.1.0 @public */ -export var FEATURES = Ember.ENV.FEATURES || {}; +export var FEATURES = assign(DEFAULT_FEATURES, Ember.ENV.FEATURES); // jshint ignore:line /** Determine whether the specified `feature` is enabled. Used by Ember's
true
Other
emberjs
ember.js
0be28eb608971605ae2f041940ffc2d98a8ffe27.json
Fix typo in query param test description
packages/ember/tests/routing/query_params_test.js
@@ -3080,7 +3080,7 @@ QUnit.test('warn user that routes query params configuration must be an Object, }, 'You passed in `[{"commitBy":{"replace":true}}]` as the value for `queryParams` but `queryParams` cannot be an Array'); }); -QUnit.test('handle routes names that class with Object.prototype properties', function() { +QUnit.test('handle routes names that clash with Object.prototype properties', function() { expect(1); Router.map(function() {
false
Other
emberjs
ember.js
0d7b8f6989a9208c2151edfa8f7352453fd8f90a.json
Remove unnecessary property access with `get`. Cleans up proxy methods in ContainerProxy and RegistryProxy.
packages/ember-runtime/lib/mixins/container_proxy.js
@@ -1,5 +1,4 @@ import run from 'ember-metal/run_loop'; -import { get } from 'ember-metal/property_get'; import { Mixin } from 'ember-metal/mixin'; export default Mixin.create({ @@ -81,7 +80,6 @@ export default Mixin.create({ function containerAlias(name) { return function () { - var container = get(this, '__container__'); - return container[name](...arguments); + return this.__container__[name](...arguments); }; }
true
Other
emberjs
ember.js
0d7b8f6989a9208c2151edfa8f7352453fd8f90a.json
Remove unnecessary property access with `get`. Cleans up proxy methods in ContainerProxy and RegistryProxy.
packages/ember-runtime/lib/mixins/registry_proxy.js
@@ -1,4 +1,3 @@ -import { get } from 'ember-metal/property_get'; import { Mixin } from 'ember-metal/mixin'; export default Mixin.create({ @@ -244,7 +243,6 @@ export default Mixin.create({ function registryAlias(name) { return function () { - var registry = get(this, '__registry__'); - return registry[name](...arguments); + return this.__registry__[name](...arguments); }; }
true
Other
emberjs
ember.js
e64c9ba077a13a5e493543a7041a090960528595.json
Replace double quotes with single quotes.
packages/ember-application/lib/system/application.js
@@ -38,7 +38,7 @@ import LinkToComponent from 'ember-routing-views/views/link'; import RoutingService from 'ember-routing/services/routing'; import ContainerDebugAdapter from 'ember-extension-support/container_debug_adapter'; import { _loaded } from 'ember-runtime/system/lazy_load'; -import RegistryProxy from "ember-runtime/mixins/registry_proxy"; +import RegistryProxy from 'ember-runtime/mixins/registry_proxy'; import environment from 'ember-metal/environment'; function props(obj) { @@ -573,7 +573,7 @@ var Application = Namespace.extend(RegistryProxy, { this._runInitializer('initializers', function(name, initializer) { Ember.assert('No application initializer named \'' + name + '\'', !!initializer); if (initializer.initialize.length === 2) { - Ember.deprecate("The `initialize` method for Application initializer '" + name + "' should take only one argument - `App`, an instance of an `Application`."); + Ember.deprecate('The `initialize` method for Application initializer \'' + name + '\' should take only one argument - `App`, an instance of an `Application`.'); initializer.initialize(App.__registry__, App); } else { initializer.initialize(App);
true
Other
emberjs
ember.js
e64c9ba077a13a5e493543a7041a090960528595.json
Replace double quotes with single quotes.
packages/ember-application/tests/system/initializers_test.js
@@ -32,13 +32,13 @@ QUnit.test('initializers require proper \'name\' and \'initialize\' properties', }); }); -QUnit.test("initializers are passed an App", function() { +QUnit.test('initializers are passed an App', function() { var MyApplication = Application.extend(); MyApplication.initializer({ name: 'initializer', initialize(App) { - ok(App instanceof Application, "initialize is passed an Application"); + ok(App instanceof Application, 'initialize is passed an Application'); } }); @@ -350,7 +350,7 @@ QUnit.test('initializers should be executed in their own context', function() { }); }); -QUnit.test("initializers should throw a deprecation warning when receiving a second argument", function() { +QUnit.test('initializers should throw a deprecation warning when receiving a second argument', function() { expect(1); var MyApplication = Application.extend();
true
Other
emberjs
ember.js
e64c9ba077a13a5e493543a7041a090960528595.json
Replace double quotes with single quotes.
packages/ember-application/tests/system/reset_test.js
@@ -241,7 +241,7 @@ QUnit.test('With ember-data like initializer and constant', function() { }; Application.initializer({ - name: "store", + name: 'store', initialize(application) { application.unregister('store:main'); application.register('store:main', application.Store);
true
Other
emberjs
ember.js
e64c9ba077a13a5e493543a7041a090960528595.json
Replace double quotes with single quotes.
packages/ember/tests/default_initializers_test.js
@@ -26,8 +26,8 @@ QUnit.test('Default objects are registered', function(assert) { App.instanceInitializer({ name: 'test', initialize(instance) { - assert.strictEqual(instance.resolveRegistration("component:-text-field"), TextField, "TextField was registered"); - assert.strictEqual(instance.resolveRegistration("component:-checkbox"), Checkbox, "Checkbox was registered"); + assert.strictEqual(instance.resolveRegistration('component:-text-field'), TextField, 'TextField was registered'); + assert.strictEqual(instance.resolveRegistration('component:-checkbox'), Checkbox, 'Checkbox was registered'); } });
true
Other
emberjs
ember.js
93a95c6bd7533664116e17cc922fda3c2aecd20e.json
Introduce ContainerProxy mixin. Mix in to `ApplicationInstance` class to provide public access to a few select methods on the encapsulated container.
packages/ember-application/lib/system/application-instance.js
@@ -10,7 +10,8 @@ import EmberObject from 'ember-runtime/system/object'; import run from 'ember-metal/run_loop'; import { computed } from 'ember-metal/computed'; import Registry from 'container/registry'; -import RegistryProxy from "ember-runtime/mixins/registry_proxy"; +import RegistryProxy from 'ember-runtime/mixins/registry_proxy'; +import ContainerProxy from 'ember-runtime/mixins/container_proxy'; /** The `ApplicationInstance` encapsulates all of the stateful aspects of a @@ -35,16 +36,7 @@ import RegistryProxy from "ember-runtime/mixins/registry_proxy"; @public */ -export default EmberObject.extend(RegistryProxy, { - /** - The application instance's container. The container stores all of the - instance-specific state for this application run. - - @property {Ember.Container} container - @public - */ - container: null, - +export default EmberObject.extend(RegistryProxy, ContainerProxy, { /** The `Application` for which this is an instance. @@ -95,7 +87,7 @@ export default EmberObject.extend(RegistryProxy, { registry.makeToString = applicationRegistry.makeToString; // Create a per-instance container from the instance's registry - this.container = registry.container(); + this.__container__ = registry.container(); // Register this instance in the per-instance registry. // @@ -108,7 +100,7 @@ export default EmberObject.extend(RegistryProxy, { }, router: computed(function() { - return this.container.lookup('router:main'); + return this.lookup('router:main'); }).readOnly(), /** @@ -195,7 +187,7 @@ export default EmberObject.extend(RegistryProxy, { @private */ setupEventDispatcher() { - var dispatcher = this.container.lookup('event_dispatcher:main'); + var dispatcher = this.lookup('event_dispatcher:main'); dispatcher.setup(this.customEvents, this.rootElement); return dispatcher; @@ -206,6 +198,6 @@ export default EmberObject.extend(RegistryProxy, { */ willDestroy() { this._super(...arguments); - run(this.container, 'destroy'); + run(this.__container__, 'destroy'); } });
true
Other
emberjs
ember.js
93a95c6bd7533664116e17cc922fda3c2aecd20e.json
Introduce ContainerProxy mixin. Mix in to `ApplicationInstance` class to provide public access to a few select methods on the encapsulated container.
packages/ember-application/lib/system/application.js
@@ -338,13 +338,13 @@ var Application = Namespace.extend(RegistryProxy, { // For the default instance only, set the view registry to the global // Ember.View.views hash for backwards-compatibility. - EmberView.views = instance.container.lookup('-view-registry:main'); + EmberView.views = instance.lookup('-view-registry:main'); // TODO2.0: Legacy support for App.__container__ // and global methods on App that rely on a single, // default instance. this.__deprecatedInstance__ = instance; - this.__container__ = instance.container; + this.__container__ = instance.__container__; return instance; },
true
Other
emberjs
ember.js
93a95c6bd7533664116e17cc922fda3c2aecd20e.json
Introduce ContainerProxy mixin. Mix in to `ApplicationInstance` class to provide public access to a few select methods on the encapsulated container.
packages/ember-runtime/lib/mixins/container_proxy.js
@@ -0,0 +1,87 @@ +import run from 'ember-metal/run_loop'; +import { get } from 'ember-metal/property_get'; +import { Mixin } from 'ember-metal/mixin'; + +export default Mixin.create({ + /** + The container stores state. + + @private + @property {Ember.Container} __container__ + */ + __container__: 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 + var registry = new Registry(); + var container = registry.container(); + + registry.register('api:twitter', Twitter); + + var twitter = container.lookup('api:twitter'); + + twitter instanceof Twitter; // => true + + // by default the container will return singletons + var 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 + var registry = new Registry(); + var container = registry.container(); + + registry.register('api:twitter', Twitter); + + var twitter = container.lookup('api:twitter', { singleton: false }); + var twitter2 = container.lookup('api:twitter', { singleton: false }); + + twitter === twitter2; //=> false + ``` + + @public + @method lookup + @param {String} fullName + @param {Object} options + @return {any} + */ + lookup: containerAlias('lookup'), + + /** + Given a fullName return the corresponding factory. + + @public + @method lookupFactory + @param {String} fullName + @return {any} + */ + lookupFactory: containerAlias('lookupFactory'), + + /** + @private + */ + willDestroy() { + this._super(...arguments); + + if (this.__container__) { + run(this.__container__, 'destroy'); + } + } +}); + +function containerAlias(name) { + return function () { + var container = get(this, '__container__'); + return container[name](...arguments); + }; +}
true
Other
emberjs
ember.js
b06bd88352228cbc826b3a0e033936b50506260e.json
Simplify ApplicationInstance creation. Pass the related Application, which the instance can inspect to obtain the initialization data that it needs. This eliminates the need to set `applicationRegistry` on the instance, which was always an anti-pattern.
packages/ember-application/lib/system/application-instance.js
@@ -46,13 +46,12 @@ export default EmberObject.extend(RegistryProxy, { container: null, /** - The application's registry. The registry contains the classes, templates, - and other code that makes up the application. + The `Application` for which this is an instance. - @property {Ember.Registry} registry + @property {Ember.Application} application @private */ - applicationRegistry: null, + application: null, /** The DOM events for which the event dispatcher should listen. @@ -80,14 +79,20 @@ export default EmberObject.extend(RegistryProxy, { init() { this._super(...arguments); + var application = get(this, 'application'); + + set(this, 'customEvents', get(application, 'customEvents')); + set(this, 'rootElement', get(application, 'rootElement')); + // Create a per-instance registry that will use the application's registry // as a fallback for resolving registrations. + var applicationRegistry = get(application, 'registry'); var registry = this.registry = new Registry({ - fallback: this.applicationRegistry, - resolver: this.applicationRegistry.resolver + fallback: applicationRegistry, + resolver: applicationRegistry.resolver }); - registry.normalizeFullName = this.applicationRegistry.normalizeFullName; - registry.makeToString = this.applicationRegistry.makeToString; + registry.normalizeFullName = applicationRegistry.normalizeFullName; + registry.makeToString = applicationRegistry.makeToString; // Create a per-instance container from the instance's registry this.container = registry.container(); @@ -99,7 +104,7 @@ export default EmberObject.extend(RegistryProxy, { // 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.registry.register('-application-instance:main', this, { instantiate: false }); + this.register('-application-instance:main', this, { instantiate: false }); }, router: computed(function() {
true
Other
emberjs
ember.js
b06bd88352228cbc826b3a0e033936b50506260e.json
Simplify ApplicationInstance creation. Pass the related Application, which the instance can inspect to obtain the initialization data that it needs. This eliminates the need to set `applicationRegistry` on the instance, which was always an anti-pattern.
packages/ember-application/lib/system/application.js
@@ -329,9 +329,7 @@ var Application = Namespace.extend(RegistryProxy, { */ buildInstance() { return ApplicationInstance.create({ - customEvents: get(this, 'customEvents'), - rootElement: get(this, 'rootElement'), - applicationRegistry: this.registry + application: this }); },
true
Other
emberjs
ember.js
ca6179249a62943fa84b26e39f1b848e1690dcb8.json
Introduce RegistryProxy mixin. Mix in to both `Application` and `ApplicationInstance` classes to provide consistent public access to their internally maintained registries.
packages/ember-application/lib/system/application-instance.js
@@ -10,6 +10,7 @@ import EmberObject from 'ember-runtime/system/object'; import run from 'ember-metal/run_loop'; import { computed } from 'ember-metal/computed'; import Registry from 'container/registry'; +import RegistryProxy from "ember-runtime/mixins/registry_proxy"; /** The `ApplicationInstance` encapsulates all of the stateful aspects of a @@ -34,7 +35,7 @@ import Registry from 'container/registry'; @public */ -export default EmberObject.extend({ +export default EmberObject.extend(RegistryProxy, { /** The application instance's container. The container stores all of the instance-specific state for this application run. @@ -53,15 +54,6 @@ export default EmberObject.extend({ */ applicationRegistry: null, - /** - The registry for this application instance. It should use the - `applicationRegistry` as a fallback. - - @property {Ember.Registry} registry - @private - */ - registry: null, - /** The DOM events for which the event dispatcher should listen. @@ -90,15 +82,15 @@ export default EmberObject.extend({ // Create a per-instance registry that will use the application's registry // as a fallback for resolving registrations. - this.registry = new Registry({ + var registry = this.registry = new Registry({ fallback: this.applicationRegistry, resolver: this.applicationRegistry.resolver }); - this.registry.normalizeFullName = this.applicationRegistry.normalizeFullName; - this.registry.makeToString = this.applicationRegistry.makeToString; + registry.normalizeFullName = this.applicationRegistry.normalizeFullName; + registry.makeToString = this.applicationRegistry.makeToString; // Create a per-instance container from the instance's registry - this.container = this.registry.container(); + this.container = registry.container(); // Register this instance in the per-instance registry. //
true
Other
emberjs
ember.js
ca6179249a62943fa84b26e39f1b848e1690dcb8.json
Introduce RegistryProxy mixin. Mix in to both `Application` and `ApplicationInstance` classes to provide consistent public access to their internally maintained registries.
packages/ember-application/lib/system/application.js
@@ -38,6 +38,7 @@ import LinkToComponent from 'ember-routing-views/views/link'; import RoutingService from 'ember-routing/services/routing'; import ContainerDebugAdapter from 'ember-extension-support/container_debug_adapter'; import { _loaded } from 'ember-runtime/system/lazy_load'; +import RegistryProxy from "ember-runtime/mixins/registry_proxy"; import environment from 'ember-metal/environment'; function props(obj) { @@ -194,7 +195,7 @@ var librariesRegistered = false; @public */ -var Application = Namespace.extend({ +var Application = Namespace.extend(RegistryProxy, { _suppressDeferredDeprecation: true, /** @@ -425,120 +426,17 @@ var Application = Namespace.extend({ }, /** - Registers a factory that can be used for dependency injection (with - `App.inject`) or for service lookup. Each factory is registered with - a full name including two parts: `type:name`. + Calling initialize manually is not supported. - A simple example: + Please see Ember.Application#advanceReadiness and + Ember.Application#deferReadiness. - ```javascript - var 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 - var App = Ember.Application.create(); - var 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 - var 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() { - this.registry.register(...arguments); - }, - - /** - 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 - var App = Ember.Application.create(); - var 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(<full_name or type>, <property name>, <full_name>) - 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 `Ember.MODEL_FACTORY_INJECTIONS` - to `true`. - - @method inject - @param factoryNameOrType {String} - @param property {String} - @param injectionName {String} - @public - **/ - inject() { - this.registry.injection(...arguments); + @private + @deprecated + @method initialize + **/ + initialize() { + Ember.deprecate('Calling initialize manually is not supported. Please see Ember.Application#advanceReadiness and Ember.Application#deferReadiness'); }, /**
true
Other
emberjs
ember.js
ca6179249a62943fa84b26e39f1b848e1690dcb8.json
Introduce RegistryProxy mixin. Mix in to both `Application` and `ApplicationInstance` classes to provide consistent public access to their internally maintained registries.
packages/ember-runtime/lib/mixins/registry_proxy.js
@@ -0,0 +1,250 @@ +import { get } from 'ember-metal/property_get'; +import { Mixin } from 'ember-metal/mixin'; + +export default 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 + var 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 + var App = Ember.Application.create(); + var 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 + var 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 }); + ``` + + @public + @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 + var App = Ember.Application.create(); + var 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'), + + /** + Check if a factory is registered. + + @public + @method hasRegistration + @param {String} fullName + @return {Boolean} + */ + hasRegistration: registryAlias('has'), + + /** + Register an option for a particular factory. + + @public + @method registerOption + @param {String} fullName + @param {String} optionName + @param {Object} options + */ + registerOption: registryAlias('option'), + + /** + Return a specific registered option for a particular factory. + + @public + @method registeredOption + @param {String} fullName + @param {String} optionName + @return {Object} options + */ + registeredOption: registryAlias('getOption'), + + /** + Register options for a particular factory. + + @public + @method registerOptions + @param {String} fullName + @param {Object} options + */ + registerOptions: registryAlias('options'), + + /** + Return registered options for a particular factory. + + @public + @method registeredOptions + @param {String} fullName + @return {Object} options + */ + registeredOptions: registryAlias('getOptions'), + + /** + Allow registering options for all factories of a type. + + ```javascript + var App = Ember.Application.create(); + var 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); + + var twitter = appInstance.lookup('connection:twitter'); + var twitter2 = appInstance.lookup('connection:twitter'); + + twitter === twitter2; // => false + + var facebook = appInstance.lookup('connection:facebook'); + var facebook2 = appInstance.lookup('connection:facebook'); + + facebook === facebook2; // => false + ``` + + @public + @method registerOptionsForType + @param {String} type + @param {Object} options + */ + registerOptionsForType: registryAlias('optionsForType'), + + /** + Return the registered options for all factories of a type. + + @public + @method registeredOptionsForType + @param {String} type + @return {Object} options + */ + registeredOptionsForType: registryAlias('getOptionsForType'), + + /** + 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 + var App = Ember.Application.create(); + var 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(<full_name or type>, <property name>, <full_name>) + 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 `Ember.MODEL_FACTORY_INJECTIONS` + to `true`. + + @public + @method inject + @param factoryNameOrType {String} + @param property {String} + @param injectionName {String} + **/ + inject: registryAlias('injection') +}); + +function registryAlias(name) { + return function () { + var registry = get(this, 'registry'); + return registry[name](...arguments); + }; +}
true
Other
emberjs
ember.js
12bca9f7fcdc7701e61f1f84af50919c0065e7af.json
Fix JSHint error in ember-debug/main.
packages/ember-debug/lib/main.js
@@ -1,5 +1,3 @@ -/*global __fail__*/ - import Ember from 'ember-metal/core'; import { registerDebugFunction } from 'ember-metal/assert'; import isEnabled, { FEATURES } from 'ember-metal/features';
false
Other
emberjs
ember.js
f137f831e3c5d9ef0faf1f83a3dca7cbc7bfffe1.json
Update deprecations in ember-views package
packages/ember-views/lib/compat/attrs-proxy.js
@@ -94,7 +94,7 @@ let AttrsProxyMixin = { if (attrs && key in attrs) { // do not deprecate accessing `this[key]` at this time. // add this back when we have a proper migration path - // Ember.deprecate(deprecation(key)); + // Ember.deprecate(deprecation(key), { id: 'ember-views.', until: '3.0.0' }); let possibleCell = get(attrs, key); if (possibleCell && possibleCell[MUTABLE_CELL]) {
true
Other
emberjs
ember.js
f137f831e3c5d9ef0faf1f83a3dca7cbc7bfffe1.json
Update deprecations in ember-views package
packages/ember-views/lib/compat/metamorph_view.js
@@ -26,9 +26,12 @@ export var _Metamorph = Mixin.create({ init() { this._super.apply(this, arguments); Ember.deprecate('Supplying a tagName to Metamorph views is unreliable and is deprecated.' + - ' You may be setting the tagName on a Handlebars helper that creates a Metamorph.', !this.tagName); + ' You may be setting the tagName on a Handlebars helper that creates a Metamorph.', + !this.tagName, + { id: 'ember-views.metamorph-tag-name', until: '2.4.0' }); - Ember.deprecate(`Using ${this.__metamorphType} is deprecated.`); + Ember.deprecate(`Using ${this.__metamorphType} is deprecated.`, false, + { id: 'ember-views.metamorph', until: '2.4.0' }); } });
true
Other
emberjs
ember.js
f137f831e3c5d9ef0faf1f83a3dca7cbc7bfffe1.json
Update deprecations in ember-views package
packages/ember-views/lib/compat/render_buffer.js
@@ -131,7 +131,8 @@ export function renderComponentWithBuffer(component, contextualElement, dom) { */ export default function RenderBuffer(domHelper) { - Ember.deprecate('`Ember.RenderBuffer` is deprecated.'); + Ember.deprecate('`Ember.RenderBuffer` is deprecated.', false, + { id: 'ember-views.render-buffer', until: '3.0.0' }); this.buffer = null; this.childViews = []; this.attrNodes = []; @@ -596,7 +597,9 @@ RenderBuffer.prototype = { if (this._outerContextualElement === undefined) { Ember.deprecate('The render buffer expects an outer contextualElement to exist.' + ' This ensures DOM that requires context is correctly generated (tr, SVG tags).' + - ' Defaulting to document.body, but this will be removed in the future'); + ' Defaulting to document.body, but this will be removed in the future', + false, + { id: 'ember-views.render-buffer-contextual-element', until: '3.0.0' }); this.outerContextualElement = document.body; } return this._outerContextualElement;
true
Other
emberjs
ember.js
f137f831e3c5d9ef0faf1f83a3dca7cbc7bfffe1.json
Update deprecations in ember-views package
packages/ember-views/lib/mixins/component_template_deprecation.js
@@ -51,6 +51,8 @@ export default Mixin.create({ delete props['template']; } - Ember.deprecate('Do not specify ' + deprecatedProperty + ' on a Component, use ' + replacementProperty + ' instead.', !deprecatedProperty); + Ember.deprecate('Do not specify ' + deprecatedProperty + ' on a Component, use ' + replacementProperty + ' instead.', + !deprecatedProperty, + { id: 'ember-views.component-deprecated-template-layout-properties', until: '3.0.0' }); } });
true
Other
emberjs
ember.js
f137f831e3c5d9ef0faf1f83a3dca7cbc7bfffe1.json
Update deprecations in ember-views package
packages/ember-views/lib/mixins/legacy_view_support.js
@@ -69,7 +69,8 @@ var LegacyViewSupport = Mixin.create({ @private */ nearestChildOf(klass) { - Ember.deprecate('nearestChildOf has been deprecated.'); + Ember.deprecate('nearestChildOf has been deprecated.', false, + { id: 'ember-views.nearest-child-of', until: '3.0.0' }); var view = get(this, 'parentView'); @@ -90,7 +91,9 @@ var LegacyViewSupport = Mixin.create({ @private */ nearestInstanceOf(klass) { - Ember.deprecate('nearestInstanceOf is deprecated and will be removed from future releases. Use nearestOfType.'); + Ember.deprecate('nearestInstanceOf is deprecated and will be removed from future releases. Use nearestOfType.', + false, + { id: 'ember-views.nearest-instance-of', until: '3.0.0' }); var view = get(this, 'parentView'); while (view) {
true
Other
emberjs
ember.js
f137f831e3c5d9ef0faf1f83a3dca7cbc7bfffe1.json
Update deprecations in ember-views package
packages/ember-views/lib/mixins/view_state_support.js
@@ -3,7 +3,9 @@ import { Mixin } from 'ember-metal/mixin'; var ViewStateSupport = Mixin.create({ transitionTo(state) { - Ember.deprecate('Ember.View#transitionTo has been deprecated, it is for internal use only'); + Ember.deprecate('Ember.View#transitionTo has been deprecated, it is for internal use only', + false, + { id: 'ember-views.view-transition-to', until: '2.4.0' }); this._transitionTo(state); },
true
Other
emberjs
ember.js
f137f831e3c5d9ef0faf1f83a3dca7cbc7bfffe1.json
Update deprecations in ember-views package
packages/ember-views/lib/system/build-component-template.js
@@ -120,7 +120,9 @@ function tagNameFor(view) { if (tagName !== null && typeof tagName === 'object' && tagName.isDescriptor) { tagName = get(view, 'tagName'); - Ember.deprecate('In the future using a computed property to define tagName will not be permitted. That value will be respected, but changing it will not update the element.', !tagName); + Ember.deprecate('In the future using a computed property to define tagName will not be permitted. That value will be respected, but changing it will not update the element.', + !tagName, + { id: 'ember-views.computed-tag-name', until: '2.0.0' }); } if (tagName === null || tagName === undefined) {
true
Other
emberjs
ember.js
f137f831e3c5d9ef0faf1f83a3dca7cbc7bfffe1.json
Update deprecations in ember-views package
packages/ember-views/lib/views/component.js
@@ -157,7 +157,9 @@ var Component = View.extend(TargetActionSupport, ComponentTemplateDeprecation, { */ template: computed('_template', { get() { - Ember.deprecate(`Accessing 'template' in ${this} is deprecated. To determine if a block was specified to ${this} please use '{{#if hasBlock}}' in the components layout.`); + Ember.deprecate(`Accessing 'template' in ${this} is deprecated. To determine if a block was specified to ${this} please use '{{#if hasBlock}}' in the components layout.`, + false, + { id: 'ember-views.component-template-get', until: '3.0.0' }); return get(this, '_template'); },
true
Other
emberjs
ember.js
f137f831e3c5d9ef0faf1f83a3dca7cbc7bfffe1.json
Update deprecations in ember-views package
packages/ember-views/lib/views/container_view.js
@@ -174,15 +174,18 @@ var ContainerView = View.extend(MutableArray, { willWatchProperty(prop) { Ember.deprecate( 'ContainerViews should not be observed as arrays. This behavior will change in future implementations of ContainerView.', - !prop.match(/\[]/) && prop.indexOf('@') !== 0 + !prop.match(/\[]/) && prop.indexOf('@') !== 0, + { id: 'ember-views.container-views-array-observed', until: '2.4.0' } ); }, init() { this._super(...arguments); var userChildViews = get(this, 'childViews'); - Ember.deprecate('Setting `childViews` on a Container is deprecated.', Ember.isEmpty(userChildViews)); + Ember.deprecate('Setting `childViews` on a Container is deprecated.', + Ember.isEmpty(userChildViews), + { id: 'ember-views.container-child-views', until: '2.4.0' }); // redefine view's childViews property that was obliterated // 2.0TODO: Don't Ember.A() this so users disabling prototype extensions @@ -305,7 +308,13 @@ var ContainerView = View.extend(MutableArray, { export var DeprecatedContainerView = ContainerView.extend({ init() { - Ember.deprecate('Ember.ContainerView is deprecated.', !!Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT , { url: 'http://emberjs.com/deprecations/v1.x/#toc_ember-containerview' }); + Ember.deprecate('Ember.ContainerView is deprecated.', + !!Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT, + { + url: 'http://emberjs.com/deprecations/v1.x/#toc_ember-containerview', + id: 'ember-views.container-view', + until: '2.4.0' + }); this._super.apply(this, arguments); } });
true
Other
emberjs
ember.js
f137f831e3c5d9ef0faf1f83a3dca7cbc7bfffe1.json
Update deprecations in ember-views package
packages/ember-views/lib/views/core_view.js
@@ -135,7 +135,9 @@ CoreView.reopenClass({ export var DeprecatedCoreView = CoreView.extend({ init() { - Ember.deprecate('Ember.CoreView is deprecated. Please use Ember.View.', false); + Ember.deprecate('Ember.CoreView is deprecated. Please use Ember.View.', + false, + { id: 'ember-views.core-view', until: '2.4.0' }); this._super.apply(this, arguments); } });
true
Other
emberjs
ember.js
f137f831e3c5d9ef0faf1f83a3dca7cbc7bfffe1.json
Update deprecations in ember-views package
packages/ember-views/lib/views/select.js
@@ -672,7 +672,13 @@ var Select = View.extend({ var DeprecatedSelect = Select.extend({ init() { this._super(...arguments); - Ember.deprecate(`Ember.Select is deprecated. Consult the Deprecations Guide for a migration strategy.`, !!Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT, { url: 'http://emberjs.com/deprecations/v1.x/#toc_ember-select' }); + Ember.deprecate(`Ember.Select is deprecated. Consult the Deprecations Guide for a migration strategy.`, + !!Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT, + { + url: 'http://emberjs.com/deprecations/v1.x/#toc_ember-select', + id: 'ember-views.select-deprecated', + until: '2.4.0' + }); } });
true
Other
emberjs
ember.js
f137f831e3c5d9ef0faf1f83a3dca7cbc7bfffe1.json
Update deprecations in ember-views package
packages/ember-views/lib/views/view.js
@@ -40,7 +40,9 @@ function K() { return this; } @submodule ember-views */ -Ember.warn('The VIEW_PRESERVES_CONTEXT flag has been removed and the functionality can no longer be disabled.', Ember.ENV.VIEW_PRESERVES_CONTEXT !== false); +Ember.warn('The VIEW_PRESERVES_CONTEXT flag has been removed and the functionality can no longer be disabled.', + Ember.ENV.VIEW_PRESERVES_CONTEXT !== false, + { id: 'ember-views.view-preserves-context-flag', until: '2.0.0' }); /** Global hash of shared templates. This will automatically be populated @@ -1334,15 +1336,21 @@ var View = CoreView.extend( scheduleRevalidate(node, label, manualRerender) { if (node && !this._dispatching && node.guid in this.env.renderedNodes) { if (manualRerender) { - Ember.deprecate(`You manually rerendered ${label} (a parent component) from a child component during the rendering process. This rarely worked in Ember 1.x and will be removed in Ember 2.0`); + Ember.deprecate(`You manually rerendered ${label} (a parent component) from a child component during the rendering process. This rarely worked in Ember 1.x and will be removed in Ember 2.0`, + false, + { id: 'ember-views.manual-parent-rerender', until: '3.0.0' }); } else { - Ember.deprecate(`You modified ${label} twice in a single render. This was unreliable in Ember 1.x and will be removed in Ember 2.0`); + Ember.deprecate(`You modified ${label} twice in a single render. This was unreliable in Ember 1.x and will be removed in Ember 2.0`, + false, + { id: 'ember-views.render-double-modify', until: '3.0.0' }); } run.scheduleOnce('render', this, this.revalidate); return; } - Ember.deprecate(`A property of ${this} was modified inside the ${this._dispatching} hook. You should never change properties on components, services or models during ${this._dispatching} because it causes significant performance degradation.`, !this._dispatching); + Ember.deprecate(`A property of ${this} was modified inside the ${this._dispatching} hook. You should never change properties on components, services or models during ${this._dispatching} because it causes significant performance degradation.`, + !this._dispatching, + { id: 'ember-views.dispatching-modify-property', until: '3.0.0' }); if (!this.scheduledRevalidation || this._dispatching) { this.scheduledRevalidation = true; @@ -1525,7 +1533,13 @@ View.childViewsProperty = childViewsProperty; var DeprecatedView = View.extend({ init() { this._super(...arguments); - Ember.deprecate(`Ember.View is deprecated. Consult the Deprecations Guide for a migration strategy.`, !!Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT, { url: 'http://emberjs.com/deprecations/v1.x/#toc_ember-view' }); + Ember.deprecate(`Ember.View is deprecated. Consult the Deprecations Guide for a migration strategy.`, + !!Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT, + { + url: 'http://emberjs.com/deprecations/v1.x/#toc_ember-view', + id: 'ember-views.view-deprecated', + until: '2.4.0' + }); } });
true
Other
emberjs
ember.js
0425ad642a10545865ed6aa1a70c8cb072b7297f.json
Update Ember.deprecate in ember-template-compiler In some cases, ids have three level due to them being all in the same method. Some deprecations are marked `until` 2.0 since they are already listed in the deprecation page.
packages/ember-template-compiler/lib/plugins/deprecate-view-and-controller-paths.js
@@ -62,7 +62,7 @@ function deprecatePath(moduleName, node, path) { } return noDeprecate; - }, { url: 'http://emberjs.com/deprecations/v1.x#toc_view-and-controller-template-keywords', id: (path.parts && path.parts[0] === 'view' ? 'view.keyword.view' : 'view.keyword.controller') }); + }, { url: 'http://emberjs.com/deprecations/v1.x#toc_view-and-controller-template-keywords', id: (path.parts && path.parts[0] === 'view' ? 'view.keyword.view' : 'view.keyword.controller'), until: '2.0.0' }); } function validate(node) {
true
Other
emberjs
ember.js
0425ad642a10545865ed6aa1a70c8cb072b7297f.json
Update Ember.deprecate in ember-template-compiler In some cases, ids have three level due to them being all in the same method. Some deprecations are marked `until` 2.0 since they are already listed in the deprecation page.
packages/ember-template-compiler/lib/plugins/deprecate-view-helper.js
@@ -36,12 +36,16 @@ function deprecateHelper(moduleName, node) { } else if (paramValue === 'select') { deprecateSelect(moduleName, node); } else { - Ember.deprecate(`Using the \`{{view "string"}}\` helper is deprecated. ${calculateLocationDisplay(moduleName, node.loc)}`, false, { url: 'http://emberjs.com/deprecations/v1.x#toc_ember-view', id: 'view.helper' }); + Ember.deprecate(`Using the \`{{view "string"}}\` helper is deprecated. ${calculateLocationDisplay(moduleName, node.loc)}`, + false, + { url: 'http://emberjs.com/deprecations/v1.x#toc_ember-view', id: 'view.helper', until: '2.0.0' }); } } function deprecateSelect(moduleName, node) { - Ember.deprecate(`Using \`{{view "select"}}\` is deprecated. ${calculateLocationDisplay(moduleName, node.loc)}`, false, { url: 'http://emberjs.com/deprecations/v1.x#toc_ember-select', id: 'view.helper.select' }); + Ember.deprecate(`Using \`{{view "select"}}\` is deprecated. ${calculateLocationDisplay(moduleName, node.loc)}`, + false, + { url: 'http://emberjs.com/deprecations/v1.x#toc_ember-select', id: 'view.helper.select', until: '2.0.0' }); } function validate(node) {
true
Other
emberjs
ember.js
0425ad642a10545865ed6aa1a70c8cb072b7297f.json
Update Ember.deprecate in ember-template-compiler In some cases, ids have three level due to them being all in the same method. Some deprecations are marked `until` 2.0 since they are already listed in the deprecation page.
packages/ember-template-compiler/lib/plugins/transform-each-into-collection.js
@@ -18,7 +18,9 @@ TransformEachIntoCollection.prototype.transform = function TransformEachIntoColl let moduleInfo = calculateLocationDisplay(moduleName, legacyHashKey.loc); Ember.deprecate( - `Using '${legacyHashKey.key}' with '{{each}}' ${moduleInfo}is deprecated. Please refactor to a component.` + `Using '${legacyHashKey.key}' with '{{each}}' ${moduleInfo}is deprecated. Please refactor to a component.`, + false, + { id: 'ember-template-compiler.transform-each-into-collection', until: '2.0.0' } ); let list = node.params.shift();
true
Other
emberjs
ember.js
0425ad642a10545865ed6aa1a70c8cb072b7297f.json
Update Ember.deprecate in ember-template-compiler In some cases, ids have three level due to them being all in the same method. Some deprecations are marked `until` 2.0 since they are already listed in the deprecation page.
packages/ember-template-compiler/lib/plugins/transform-input-on-to-onEvent.js
@@ -51,7 +51,9 @@ TransformInputOnToOnEvent.prototype.transform = function TransformInputOnToOnEve if (normalizedOn && normalizedOn.value.type !== 'StringLiteral') { Ember.deprecate( - `Using a dynamic value for '#{normalizedOn.key}=' with the '{{input}}' helper ${moduleInfo}is deprecated.` + `Using a dynamic value for '#{normalizedOn.key}=' with the '{{input}}' helper ${moduleInfo}is deprecated.`, + false, + { id: 'ember-template-compiler.transform-input-on-to-onEvent.dynamic-value', until: '3.0.0' } ); normalizedOn.key = 'onEvent'; @@ -63,7 +65,9 @@ TransformInputOnToOnEvent.prototype.transform = function TransformInputOnToOnEve if (!action) { Ember.deprecate( - `Using '{{input ${normalizedOn.key}="${normalizedOn.value.value}" ...}}' without specifying an action ${moduleInfo}will do nothing.` + `Using '{{input ${normalizedOn.key}="${normalizedOn.value.value}" ...}}' without specifying an action ${moduleInfo}will do nothing.`, + false, + { id: 'ember-template-compiler.transform-input-on-to-onEvent.no-action', until: '3.0.0' } ); return; // exit early, if no action was available there is nothing to do @@ -80,7 +84,9 @@ TransformInputOnToOnEvent.prototype.transform = function TransformInputOnToOnEve let expected = `${normalizedOn ? normalizedOn.value.value : 'enter'}="${action.value.original}"`; Ember.deprecate( - `Using '{{input ${specifiedOn}action="${action.value.original}"}}' ${moduleInfo}is deprecated. Please use '{{input ${expected}}}' instead.` + `Using '{{input ${specifiedOn}action="${action.value.original}"}}' ${moduleInfo}is deprecated. Please use '{{input ${expected}}}' instead.`, + false, + { id: 'ember-template-compiler.transform-input-on-to-onEvent.normalized-on', until: '3.0.0' } ); if (!normalizedOn) { normalizedOn = b.pair('onEvent', b.string('enter'));
true
Other
emberjs
ember.js
0425ad642a10545865ed6aa1a70c8cb072b7297f.json
Update Ember.deprecate in ember-template-compiler In some cases, ids have three level due to them being all in the same method. Some deprecations are marked `until` 2.0 since they are already listed in the deprecation page.
packages/ember-template-compiler/lib/plugins/transform-old-binding-syntax.js
@@ -26,7 +26,11 @@ TransformOldBindingSyntax.prototype.transform = function TransformOldBindingSynt if (key.substr(-7) === 'Binding') { let newKey = key.slice(0, -7); - Ember.deprecate(`You're using legacy binding syntax: ${key}=${exprToString(value)} ${sourceInformation}. Please replace with ${newKey}=${value.original}`); + Ember.deprecate( + `You're using legacy binding syntax: ${key}=${exprToString(value)} ${sourceInformation}. Please replace with ${newKey}=${value.original}`, + false, + { id: 'ember-template-compiler.transform-old-binding-syntax', until: '3.0.0' } + ); pair.key = newKey; if (value.type === 'StringLiteral') {
true
Other
emberjs
ember.js
78b790f08c9c4a7797d595314d4226803f3d1e4b.json
Add Descriptors to eachComputedProperty
packages/ember-runtime/lib/system/core_object.js
@@ -794,7 +794,7 @@ var ClassMixinProps = { for (var name in proto) { property = proto[name]; - if (property instanceof ComputedProperty) { + if (property && property.isDescriptor) { properties.push({ name: name, meta: property._meta
true
Other
emberjs
ember.js
78b790f08c9c4a7797d595314d4226803f3d1e4b.json
Add Descriptors to eachComputedProperty
packages/ember-runtime/tests/system/object/computed_test.js
@@ -1,3 +1,4 @@ +import alias from 'ember-metal/alias'; import { computed } from 'ember-metal/computed'; import { get as emberGet } from 'ember-metal/property_get'; import { observer } from 'ember-metal/mixin'; @@ -152,7 +153,9 @@ QUnit.test('can iterate over a list of computed properties for a class', functio fooDidChange: observer('foo', function() {}), - bar: computed(function() {}) + bar: computed(function() {}), + + qux: alias('foo') }); var SubClass = MyClass.extend({ @@ -169,7 +172,7 @@ QUnit.test('can iterate over a list of computed properties for a class', functio list.push(name); }); - deepEqual(list.sort(), ['bar', 'foo'], 'watched and unwatched computed properties are iterated'); + deepEqual(list.sort(), ['bar', 'foo', 'qux'], 'watched and unwatched computed properties are iterated'); list = []; @@ -183,7 +186,7 @@ QUnit.test('can iterate over a list of computed properties for a class', functio } }); - deepEqual(list.sort(), ['bar', 'bat', 'baz', 'foo'], 'all inherited properties are included'); + 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() {
true
Other
emberjs
ember.js
013f797d22d9ac71bbb01d71bacbcc5ab681ca02.json
Add test for frozenCopy deprecation
packages/ember-runtime/lib/mixins/copyable.js
@@ -57,7 +57,7 @@ export default Mixin.create({ @private */ frozenCopy() { - Ember.deprecate('`frozenCopy` is deprecated, use Object.freeze instead.'); + Ember.deprecate('`frozenCopy` is deprecated, use `Object.freeze` instead.'); if (Freezable && Freezable.detect(this)) { return get(this, 'isFrozen') ? this : this.copy().freeze(); } else {
true
Other
emberjs
ember.js
013f797d22d9ac71bbb01d71bacbcc5ab681ca02.json
Add test for frozenCopy deprecation
packages/ember-runtime/tests/mixins/copyable_test.js
@@ -1,10 +1,25 @@ import CopyableTests from 'ember-runtime/tests/suites/copyable'; import Copyable from 'ember-runtime/mixins/copyable'; +import {Freezable} from 'ember-runtime/mixins/freezable'; import EmberObject from 'ember-runtime/system/object'; import {generateGuid} from 'ember-metal/utils'; import {set} from 'ember-metal/property_set'; import {get} from 'ember-metal/property_get'; +QUnit.module('Ember.Copyable.frozenCopy'); + +QUnit.test('should be deprecated', function() { + expectDeprecation('`frozenCopy` is deprecated, use `Object.freeze` instead.'); + + var Obj = EmberObject.extend(Freezable, Copyable, { + copy() { + return Obj.create(); + } + }); + + Obj.create().frozenCopy(); +}); + var CopyableObject = EmberObject.extend(Copyable, { id: null,
true
Other
emberjs
ember.js
35edaf26cbc6edafc7bbef063db01c17cac5a3e2.json
Remove space before parens in anon-func
STYLEGUIDE.md
@@ -127,7 +127,7 @@ if (foo === 'bara') { } // parameters -function (test, foo) { +function(test, foo) { } ```
false
Other
emberjs
ember.js
f4affcdd959af057b98a1e6e7ee4e326bebc8bc7.json
JSCS: Require spaces around operators Except for before a `,`.
.jscsrc
@@ -54,6 +54,29 @@ "with", "return" ], + "requireSpaceBeforeBinaryOperators": [ + "=", + "+", + "-", + "/", + "*", + "==", + "===", + "!=", + "!==" + ], + "requireSpaceAfterBinaryOperators": [ + "=", + ",", + "+", + "-", + "/", + "*", + "==", + "===", + "!=", + "!==" + ], "requireSpaceBetweenArguments": true, "requireSpacesAfterClosingParenthesisInFunctionDeclaration": { "beforeOpeningRoundBrace": false,
false
Other
emberjs
ember.js
e49113cb2c83880fb3656ebb306a4ec22e0e2d53.json
Update action docs. Action documentation contains a event camelize instead of dasherize. This causes some problems when people read the guides. See [guides#83](https://github.com/emberjs/guides/pull/83).
packages/ember-routing-htmlbars/lib/keywords/action.js
@@ -90,7 +90,7 @@ import closureAction from 'ember-routing-htmlbars/keywords/closure-action'; supply an `on` option to the helper to specify a different DOM event name: ```handlebars - <div {{action "anActionName" on="doubleClick"}}> + <div {{action "anActionName" on="double-click"}}> click me </div> ```
false
Other
emberjs
ember.js
a00c953c5518e4b5857f200baae5840eaf761942.json
Add repository to bower.json
bower.json
@@ -1,5 +1,9 @@ { "name": "ember", + "repository": { + "type": "git", + "url": "https://github.com/emberjs/ember.js.git" + }, "dependencies": { "jquery": "~1.11.1", "qunit": "~1.17.1",
false
Other
emberjs
ember.js
b25aa411dfeb3c3e747034b46fe4e0087bc00200.json
Add repository to config bower.json
config/package_manager_files/bower.json
@@ -5,7 +5,11 @@ "./ember.debug.js", "./ember-template-compiler.js" ], + "repository": { + "type": "git", + "url": "https://github.com/emberjs/ember.js.git" + }, "dependencies": { "jquery": ">= 1.7.0 < 2.2.0" } -} \ No newline at end of file +}
false
Other
emberjs
ember.js
ebebab8fbf5740ca25315777a541d79b602bdb46.json
Add repository field to package.json
package.json
@@ -13,6 +13,10 @@ "docs": "ember ember-cli-yuidoc", "sauce:launch": "ember sauce:launch" }, + "repository": { + "type": "git", + "url": "https://github.com/emberjs/ember.js.git" + }, "devDependencies": { "aws-sdk": "~2.1.5", "babel-plugin-feature-flags": "~0.2.0",
false
Other
emberjs
ember.js
8574876d9ffca952102e4e2a33f31f6aa57dbe1c.json
Eliminate redundant willCleanupNode hook This commit resolves a memory leak (#11501) in apps running Glimmer. The root cause of the issue was that a flag governing whether components/views remove themselves from their parent was being set incorrectly, so that when the code to cleanup a destroyed view ran, it was not removed from its parent’s `childViews` array. Specifically, three hooks are invoked when a render node is cleared: 1. `env.hooks.willCleanupNode` 2. `Morph#cleanup` 3. `env.hooks.didCleanupNode` Prior to this commit, `willCleanupNode` would blindly set the owner view’s `isDestroyingSubtree` flag if there was a view set in the `env` (i.e., basically always). Sidebar on the `isDestroyingSubtree` flag: this flag is used as a performance optimization. If a view is destroyed, we want to remove that view from its parent’s `childViews` array so that garbage collection can happen. However, it is unnecessary to remove child views from the destroyed view’s `childViews` array; the GC will take care of any clean up when the link between the view hierarchy and the destroyed view is severed. For example, imagine this hypothetical view hierarchy: A / \ B C / \ D E If the render node for view C is destroyed, we need to remove C from A’s array of child views. However, it is unnecessary to remove D or E from C’s child views, because they will be imminently removed by the GC, and temporarily lingering in the child views array does no harm. We accomplish this by setting the `isDestroyingSubtree` flag on the root-most view in a hierarchy (view A in the example above), which we call the owner view. When the render node for C is destroyed, it removes C from A’s child views array and sets the flag to true. When D and E’s render nodes are destroyed, they see that the flag has already been flipped and do not remove their associated views from C’s child views array. The memory leak manifested itself when the a render node that did not have a view associated with it was destroyed, and contained a child render node that _did_ have a view associated. For example: ```handlebars {{#if foo}} {{my-component}} {{/if}} ``` In this case, the `willCleanupNode` hook would erroneously set the flag without actually moving the `my-component` view, because the render node for the `{{if}}` does not know about the component. When the cleanup for `{{my-component}}` finally happens (in Morph#cleanup), the flag has already been set, so the render node incorrectly assumes that its view is part of a subgraph that has already been severed. As far as we can tell, the `willCleanupNode` hook is not doing any cleanup that is not already done in `Morph#cleanup`. We still do need `didCleanupNode` to clear the flag, but can leave individual render node cleanup to the render node itself.
packages/ember-views/tests/views/view/child_views_test.js
@@ -77,11 +77,11 @@ QUnit.test('should remove childViews on destroy', function() { container: { lookup() { return { - componentFor(tagName, container) { + componentFor() { return Component.extend(); }, - layoutFor(tagName, container) { + layoutFor() { return null; } };
false
Other
emberjs
ember.js
0d43d24bc27db5b6267753c93868e8565f61f670.json
Eliminate redundant willCleanupNode hook This commit resolves a memory leak (#11501) in apps running Glimmer. The root cause of the issue was that a flag governing whether components/views remove themselves from their parent was being set incorrectly, so that when the code to cleanup a destroyed view ran, it was not removed from its parent’s `childViews` array. Specifically, three hooks are invoked when a render node is cleared: 1. `env.hooks.willCleanupNode` 2. `Morph#cleanup` 3. `env.hooks.didCleanupNode` Prior to this commit, `willCleanupNode` would blindly set the owner view’s `isDestroyingSubtree` flag if there was a view set in the `env` (i.e., basically always). Sidebar on the `isDestroyingSubtree` flag: this flag is used as a performance optimization. If a view is destroyed, we want to remove that view from its parent’s `childViews` array so that garbage collection can happen. However, it is unnecessary to remove child views from the destroyed view’s `childViews` array; the GC will take care of any clean up when the link between the view hierarchy and the destroyed view is severed. For example, imagine this hypothetical view hierarchy: A / \ B C / \ D E If the render node for view C is destroyed, we need to remove C from A’s array of child views. However, it is unnecessary to remove D or E from C’s child views, because they will be imminently removed by the GC, and temporarily lingering in the child views array does no harm. We accomplish this by setting the `isDestroyingSubtree` flag on the root-most view in a hierarchy (view A in the example above), which we call the owner view. When the render node for C is destroyed, it removes C from A’s child views array and sets the flag to true. When D and E’s render nodes are destroyed, they see that the flag has already been flipped and do not remove their associated views from C’s child views array. The memory leak manifested itself when the a render node that did not have a view associated with it was destroyed, and contained a child render node that _did_ have a view associated. For example: ```handlebars {{#if foo}} {{my-component}} {{/if}} ``` In this case, the `willCleanupNode` hook would erroneously set the flag without actually moving the `my-component` view, because the render node for the `{{if}}` does not know about the component. When the cleanup for `{{my-component}}` finally happens (in Morph#cleanup), the flag has already been set, so the render node incorrectly assumes that its view is part of a subgraph that has already been severed. As far as we can tell, the `willCleanupNode` hook is not doing any cleanup that is not already done in `Morph#cleanup`. We still do need `didCleanupNode` to clear the flag, but can leave individual render node cleanup to the render node itself.
packages/ember-htmlbars/lib/env.js
@@ -20,7 +20,6 @@ import getCellOrValue from 'ember-htmlbars/hooks/get-cell-or-value'; import cleanupRenderNode from 'ember-htmlbars/hooks/cleanup-render-node'; import destroyRenderNode from 'ember-htmlbars/hooks/destroy-render-node'; import didRenderNode from 'ember-htmlbars/hooks/did-render-node'; -import willCleanupTree from 'ember-htmlbars/hooks/will-cleanup-tree'; import didCleanupTree from 'ember-htmlbars/hooks/did-cleanup-tree'; import classify from 'ember-htmlbars/hooks/classify'; import component from 'ember-htmlbars/hooks/component'; @@ -53,7 +52,6 @@ merge(emberHooks, { concat: concat, cleanupRenderNode: cleanupRenderNode, destroyRenderNode: destroyRenderNode, - willCleanupTree: willCleanupTree, didCleanupTree: didCleanupTree, didRenderNode: didRenderNode, classify: classify,
true
Other
emberjs
ember.js
0d43d24bc27db5b6267753c93868e8565f61f670.json
Eliminate redundant willCleanupNode hook This commit resolves a memory leak (#11501) in apps running Glimmer. The root cause of the issue was that a flag governing whether components/views remove themselves from their parent was being set incorrectly, so that when the code to cleanup a destroyed view ran, it was not removed from its parent’s `childViews` array. Specifically, three hooks are invoked when a render node is cleared: 1. `env.hooks.willCleanupNode` 2. `Morph#cleanup` 3. `env.hooks.didCleanupNode` Prior to this commit, `willCleanupNode` would blindly set the owner view’s `isDestroyingSubtree` flag if there was a view set in the `env` (i.e., basically always). Sidebar on the `isDestroyingSubtree` flag: this flag is used as a performance optimization. If a view is destroyed, we want to remove that view from its parent’s `childViews` array so that garbage collection can happen. However, it is unnecessary to remove child views from the destroyed view’s `childViews` array; the GC will take care of any clean up when the link between the view hierarchy and the destroyed view is severed. For example, imagine this hypothetical view hierarchy: A / \ B C / \ D E If the render node for view C is destroyed, we need to remove C from A’s array of child views. However, it is unnecessary to remove D or E from C’s child views, because they will be imminently removed by the GC, and temporarily lingering in the child views array does no harm. We accomplish this by setting the `isDestroyingSubtree` flag on the root-most view in a hierarchy (view A in the example above), which we call the owner view. When the render node for C is destroyed, it removes C from A’s child views array and sets the flag to true. When D and E’s render nodes are destroyed, they see that the flag has already been flipped and do not remove their associated views from C’s child views array. The memory leak manifested itself when the a render node that did not have a view associated with it was destroyed, and contained a child render node that _did_ have a view associated. For example: ```handlebars {{#if foo}} {{my-component}} {{/if}} ``` In this case, the `willCleanupNode` hook would erroneously set the flag without actually moving the `my-component` view, because the render node for the `{{if}}` does not know about the component. When the cleanup for `{{my-component}}` finally happens (in Morph#cleanup), the flag has already been set, so the render node incorrectly assumes that its view is part of a subgraph that has already been severed. As far as we can tell, the `willCleanupNode` hook is not doing any cleanup that is not already done in `Morph#cleanup`. We still do need `didCleanupNode` to clear the flag, but can leave individual render node cleanup to the render node itself.
packages/ember-htmlbars/lib/hooks/will-cleanup-tree.js
@@ -1,10 +0,0 @@ -export default function willCleanupTree(env, morph, destroySelf) { - var view = morph.emberView; - if (destroySelf && view && view.parentView) { - view.parentView.removeChild(view); - } - - if (view = env.view) { - view.ownerView.isDestroyingSubtree = true; - } -}
true
Other
emberjs
ember.js
0d43d24bc27db5b6267753c93868e8565f61f670.json
Eliminate redundant willCleanupNode hook This commit resolves a memory leak (#11501) in apps running Glimmer. The root cause of the issue was that a flag governing whether components/views remove themselves from their parent was being set incorrectly, so that when the code to cleanup a destroyed view ran, it was not removed from its parent’s `childViews` array. Specifically, three hooks are invoked when a render node is cleared: 1. `env.hooks.willCleanupNode` 2. `Morph#cleanup` 3. `env.hooks.didCleanupNode` Prior to this commit, `willCleanupNode` would blindly set the owner view’s `isDestroyingSubtree` flag if there was a view set in the `env` (i.e., basically always). Sidebar on the `isDestroyingSubtree` flag: this flag is used as a performance optimization. If a view is destroyed, we want to remove that view from its parent’s `childViews` array so that garbage collection can happen. However, it is unnecessary to remove child views from the destroyed view’s `childViews` array; the GC will take care of any clean up when the link between the view hierarchy and the destroyed view is severed. For example, imagine this hypothetical view hierarchy: A / \ B C / \ D E If the render node for view C is destroyed, we need to remove C from A’s array of child views. However, it is unnecessary to remove D or E from C’s child views, because they will be imminently removed by the GC, and temporarily lingering in the child views array does no harm. We accomplish this by setting the `isDestroyingSubtree` flag on the root-most view in a hierarchy (view A in the example above), which we call the owner view. When the render node for C is destroyed, it removes C from A’s child views array and sets the flag to true. When D and E’s render nodes are destroyed, they see that the flag has already been flipped and do not remove their associated views from C’s child views array. The memory leak manifested itself when the a render node that did not have a view associated with it was destroyed, and contained a child render node that _did_ have a view associated. For example: ```handlebars {{#if foo}} {{my-component}} {{/if}} ``` In this case, the `willCleanupNode` hook would erroneously set the flag without actually moving the `my-component` view, because the render node for the `{{if}}` does not know about the component. When the cleanup for `{{my-component}}` finally happens (in Morph#cleanup), the flag has already been set, so the render node incorrectly assumes that its view is part of a subgraph that has already been severed. As far as we can tell, the `willCleanupNode` hook is not doing any cleanup that is not already done in `Morph#cleanup`. We still do need `didCleanupNode` to clear the flag, but can leave individual render node cleanup to the render node itself.
packages/ember-views/tests/views/view/child_views_test.js
@@ -1,5 +1,6 @@ import run from 'ember-metal/run_loop'; import EmberView from 'ember-views/views/view'; +import Component from 'ember-views/views/component'; import { compile } from 'ember-template-compiler'; var parentView, childView; @@ -77,16 +78,11 @@ QUnit.test('should remove childViews on destroy', function() { lookup() { return { componentFor(tagName, container) { - return Ember.Component.extend({ - destroy() { - debugger; - this._super(...arguments); - } - }); + return Component.extend(); }, layoutFor(tagName, container) { - return null; + return null; } }; }
true
Other
emberjs
ember.js
09d41a474b9e3a85976b5e00362f6072c0b24fd6.json
add readme entry
README.md
@@ -52,3 +52,9 @@ versions of jQuery. 2. Run `npm test` to run a basic test suite or run `TEST_SUITE=all npm test` to run a more comprehensive suite. +## From ember-cli + +1. ember test --server +2. connect the browsers you want +3. if phantom didn't connect automatically, you can run `./bin/connect-phantom-to <optional-port>` +
false
Other
emberjs
ember.js
04163354e29d59b00d86315fbedc5e0b9d75dae0.json
prefer template string
packages/ember-views/lib/compat/render_buffer.js
@@ -478,7 +478,7 @@ RenderBuffer.prototype = { if (!canSetNameOnInputs && attrs && attrs.name) { // IE allows passing a tag to createElement. See note on `canSetNameOnInputs` above as well. - tagString = '<'+stripTagName(tagName)+' name="'+escapeAttribute(attrs.name)+'">'; + tagString = `<${stripTagName(tagName)} name="${escapeAttribute(attrs.name)}">`; } else { tagString = tagName; }
false
Other
emberjs
ember.js
377b36b263ed2e82b6ce4d8fa9bd0bafbbf7a71a.json
Fix tests that got broken by a spelling change
packages/ember-metal/tests/main_test.js
@@ -35,11 +35,11 @@ QUnit.test('SEMVER_REGEX properly validates and invalidates version numbers', fu QUnit.test('Ember.keys is deprecated', function() { expectDeprecation(function() { Ember.keys({}); - }, 'Ember.keys is deprecated in-favour of Object.keys'); + }, 'Ember.keys is deprecated in favor of Object.keys'); }); QUnit.test('Ember.keys is deprecated', function() { expectDeprecation(function() { Ember.create(null); - }, 'Ember.create is deprecated in-favour of Object.create'); + }, 'Ember.create is deprecated in favor of Object.create'); });
false
Other
emberjs
ember.js
1fc7811a45dfb6184667364067203db4e2ff45dc.json
Fix view destruction inside outlets This solution feels hacky and we need to discuss what code is really responsible for view destruction. The htmlbars code that clears the DOM does not do view destruction, which leaves us in an awkward situation where the DOM is already removed but we need to destroy the view.
packages/ember-htmlbars/lib/keywords/real_outlet.js
@@ -25,7 +25,11 @@ export default { toRender.template = topLevelViewTemplate; } - return { outletState: selectedOutletState, hasParentOutlet: env.hasParentOutlet }; + return { + outletState: selectedOutletState, + hasParentOutlet: env.hasParentOutlet, + manager: state.manager + }; }, childEnv(state, env) { @@ -68,6 +72,11 @@ export default { Ember.Logger.info('Rendering ' + toRender.name + ' with ' + ViewClass, { fullName: 'view:' + toRender.name }); } + if (state.manager) { + state.manager.destroy(); + state.manager = null; + } + var nodeManager = ViewNodeManager.create(renderNode, env, {}, options, parentView, null, null, template); state.manager = nodeManager;
true
Other
emberjs
ember.js
1fc7811a45dfb6184667364067203db4e2ff45dc.json
Fix view destruction inside outlets This solution feels hacky and we need to discuss what code is really responsible for view destruction. The htmlbars code that clears the DOM does not do view destruction, which leaves us in an awkward situation where the DOM is already removed but we need to destroy the view.
packages/ember-htmlbars/lib/node-managers/view-node-manager.js
@@ -150,7 +150,10 @@ ViewNodeManager.prototype.rerender = function(env, attrs, visitor) { }; ViewNodeManager.prototype.destroy = function() { - this.component.destroy(); + if (this.component) { + this.component.destroy(); + this.component = null; + } }; function getTemplate(componentOrView) {
true
Other
emberjs
ember.js
1fc7811a45dfb6184667364067203db4e2ff45dc.json
Fix view destruction inside outlets This solution feels hacky and we need to discuss what code is really responsible for view destruction. The htmlbars code that clears the DOM does not do view destruction, which leaves us in an awkward situation where the DOM is already removed but we need to destroy the view.
packages/ember-metal-views/lib/renderer.js
@@ -210,7 +210,7 @@ Renderer.prototype.renderElementRemoval = if (view._willRemoveElement) { view._willRemoveElement = false; - if (view._renderNode) { + if (view._renderNode && view.element && view.element.parentNode) { view._renderNode.clear(); } this.didDestroyElement(view);
true
Other
emberjs
ember.js
7ffe8f70ee2b8a5c46e61c8e257e4157d141cc09.json
Remove unused import to fix jshint This error sneaked into the repo due to #11574.
packages/ember-metal/lib/main.js
@@ -29,7 +29,6 @@ import { metaPath, setMeta, deprecatedTryCatchFinally, - deprecatedTryFinally, tryInvoke, uuid, wrap
false
Other
emberjs
ember.js
e189688d40c738ce3ccbdde39f336d50e6909432.json
Rerender link on routing state change. Test link-to with only query params provided
packages/ember-routing-views/lib/views/link.js
@@ -349,6 +349,8 @@ var LinkComponent = EmberComponent.extend({ if (get(this, 'loading')) { return get(this, 'loadingHref'); } + targetRouteName = this._handleOnlyQueryParamsSupplied(targetRouteName); + var routing = get(this, '_routing'); var queryParams = get(this, 'queryParams.values'); return routing.generateURL(targetRouteName, models, queryParams); @@ -363,6 +365,22 @@ var LinkComponent = EmberComponent.extend({ } }), + _handleOnlyQueryParamsSupplied(route) { + var params = this.attrs.params.slice(); + var lastParam = params[params.length - 1]; + if (lastParam && lastParam.isQueryParams) { + params.pop(); + } + let onlyQueryParamsSupplied = (params.length === 0); + if (onlyQueryParamsSupplied) { + var appController = this.container.lookup('controller:application'); + if (appController) { + return get(appController, 'currentRouteName'); + } + } + return route; + }, + /** The default href value to use while a link-to is loading. Only applies when tagName is 'a' @@ -437,19 +455,10 @@ var LinkComponent = EmberComponent.extend({ let targetRouteName; let models = []; - let onlyQueryParamsSupplied = (params.length === 0); - - if (onlyQueryParamsSupplied) { - var appController = this.container.lookup('controller:application'); - if (appController) { - targetRouteName = get(appController, 'currentRouteName'); - } - } else { - targetRouteName = params[0]; + targetRouteName = this._handleOnlyQueryParamsSupplied(params[0]); - for (let i = 1; i < params.length; i++) { - models.push(params[i]); - } + for (let i = 1; i < params.length; i++) { + models.push(params[i]); } let resolvedQueryParams = getResolvedQueryParams(queryParams, targetRouteName);
true
Other
emberjs
ember.js
e189688d40c738ce3ccbdde39f336d50e6909432.json
Rerender link on routing state change. Test link-to with only query params provided
packages/ember/tests/helpers/link_to_test.js
@@ -1378,3 +1378,37 @@ QUnit.test('{{link-to}} populates href with fully supplied query param values', bootApplication(); equal(Ember.$('#the-link').attr('href'), '/?bar=NAW&foo=456', 'link has right href'); }); + +QUnit.test('{{link-to}} with only query-params updates when route changes', function() { + Router.map(function() { + this.route('about'); + }); + + if (isEnabled('ember-routing-route-configured-query-params')) { + App.ApplicationRoute = Ember.Route.extend({ + queryParams: { + foo: { + defaultValue: '123' + }, + bar: { + defaultValue: 'yes' + } + } + }); + } else { + App.ApplicationController = Ember.Controller.extend({ + queryParams: ['foo', 'bar'], + foo: '123', + bar: 'yes' + }); + } + + Ember.TEMPLATES.application = compile('{{#link-to (query-params foo=\'456\' bar=\'NAW\') id=\'the-link\'}}Index{{/link-to}}'); + bootApplication(); + equal(Ember.$('#the-link').attr('href'), '/?bar=NAW&foo=456', 'link has right href'); + + Ember.run(function() { + router.handleURL('/about'); + }); + equal(Ember.$('#the-link').attr('href'), '/about?bar=NAW&foo=456', 'link has right href'); +});
true
Other
emberjs
ember.js
b758625a2d3a1bc383a4d97895f0a67411a903ee.json
Enable features for 2.0.0.
features.json
@@ -6,7 +6,7 @@ "ember-htmlbars-component-helper": true, "ember-htmlbars-inline-if-helper": true, "ember-htmlbars-attribute-syntax": true, - "ember-htmlbars-each-in": null, + "ember-htmlbars-each-in": true, "ember-routing-transitioning-classes": true, "ember-testing-checkbox-helpers": null, "ember-metal-stream": null, @@ -19,7 +19,7 @@ "ember-routing-route-configured-query-params": null, "ember-libraries-isregistered": null, "ember-routing-htmlbars-improved-actions": true, - "ember-htmlbars-get-helper": null, + "ember-htmlbars-get-helper": true, "ember-htmlbars-helper": true, "ember-htmlbars-dashless-helpers": true },
false
Other
emberjs
ember.js
4a2f37a500b2e8047e5af80f57419105f65dea0c.json
Add Ember 1.13.0 to CHANGELOG.
CHANGELOG.md
@@ -1,5 +1,65 @@ # Ember Changelog +### 1.13.0 (June 12, 2015) + +- [#11270](https://github.com/emberjs/ember.js/pull/11270) [BUGFIX] Ensure view registry is propagated to components. +- [#11273](https://github.com/emberjs/ember.js/pull/11273) [BUGFIX] Downgrade Ember.Service without proper inheritance to a deprecation (instead of an assertion). +- [#11274](https://github.com/emberjs/ember.js/pull/11274) [BUGFIX] Unify template compiler deprecations so that they can report the proper location of the deprecation. +- [#11279](https://github.com/emberjs/ember.js/pull/11279) [DEPRECATION] Deprecate `{{#each foo in bar}}{{/each}}`. +- [#11229](https://github.com/emberjs/ember.js/pull/11229) [BUGFIX] Prevent views from having access to component lifecycle hooks. +- [#11286](https://github.com/emberjs/ember.js/pull/11286) [DEPRECATION] Deprecate `Ember.EnumerableUtils`. +- [#11338](https://github.com/emberjs/ember.js/pull/11338) [BUGFIX] Ensure `parentView` is available properly. +- [#11313](https://github.com/emberjs/ember.js/pull/11313) [DEPRECATION] Allow deprecated access to `template` in component to determine if a block was provided. +- [#11339](https://github.com/emberjs/ember.js/pull/11339) Add special values (`@index` or `@guid`) to `{{each}}`'s keyPath. +- [#11360](https://github.com/emberjs/ember.js/pull/11360) Add warning message when using `{{each}}` without specifying `key`. +- [#11348](https://github.com/emberjs/ember.js/pull/11348) [BUGFIX] Provide useful errors when a closure action is not found. +- [#11264](https://github.com/emberjs/ember.js/pull/11264) Add `{{concat}}` helper. +- [#11362](https://github.com/emberjs/ember.js/pull/11362) / [#11365](https://github.com/emberjs/ember.js/pull/11365) [DOC] Ensure all documentation comments include `@public` or `@private`. +- [#11278](https://github.com/emberjs/ember.js/pull/11278) Implement Ember.Helper. Read [emberjs/rfcs#53](https://github.com/emberjs/rfcs/pull/53) for more details. +- [#11373](https://github.com/emberjs/ember.js/pull/11373) [BUGFIX] Fix issue with multiple actions in a single element. +- [#11387](https://github.com/emberjs/ember.js/pull/11387) [DEPRECATION] Deprecate `Ember.View`. +- [#11389](https://github.com/emberjs/ember.js/pull/11389) [DEPRECATION] Deprecate `{{view}}` helper. +- [#11394](https://github.com/emberjs/ember.js/pull/11394) [DEPRECATION] Add `Ember.LinkComponent` and deprecate `Ember.LinkView`. +- [#11400](https://github.com/emberjs/ember.js/pull/11400) [DEPRECATION] Deprecate `Ember.computed.any`. +- [#11330](https://github.com/emberjs/ember.js/pull/11330) [BUGFIX] Ensure that `{{each}}` can properly transition into and out of its inverse state. +- [#11416](https://github.com/emberjs/ember.js/pull/11416) [DEPRECATION] Deprecate `Ember.Select`. +- [#11403](https://github.com/emberjs/ember.js/pull/11403) [DEPRECATION] Deprecate `Ember.arrayComputed`, `Ember.ReduceComputedProperty`, `Ember.ArrayComputedProperty`, and `Ember.reduceComputed`. +- [#11401](https://github.com/emberjs/ember.js/pull/11401) [DEPRECATION] Deprecate `{{view` and `{{controller` template local keywords. +- [#11329](https://github.com/emberjs/ember.js/pull/11329) [BUGFIX] Fix issue with `{{component}}` helper not properly cleaning up components after they have been replaced. +- [#11393](https://github.com/emberjs/ember.js/pull/11393) Implement support for automatic registration of all helpers (with or without a dash). Requires ember-resolver@0.1.17 or higher if using ember-cli. Read [emberjs/rfcs#58](https://github.com/emberjs/rfcs/pull/58) for more details. +- [#11425](https://github.com/emberjs/ember.js/pull/11425) [BUGFIX] Prevent `willDestroyElement` from being called multiple times on the same component. +- [#11138](https://github.com/emberjs/ember.js/pull/11138) Add a better deprecation for `{{bind-attr}}`. +- [#11201](https://github.com/emberjs/ember.js/pull/11201) [BUGFIX] Fix `currentURL` test helper. +- [#11161](https://github.com/emberjs/ember.js/pull/11161) [BUGFIX] Fix initial selection for select with optgroup. +- [#10980](https://github.com/emberjs/ember.js/pull/10980) [BUGFIX] Fix `Ember.String.dasherize`, `Ember.String.underscore`, `Ember.String.capitalize`, `Ember.String.classify` for multi-word input values. +- [#11187](https://github.com/emberjs/ember.js/pull/11187) [BUGFIX] Handle mut cell action names. +- [#11194](https://github.com/emberjs/ember.js/pull/11194) [BUGFIX] Ensure `classNameBindings` properly handles multiple entries. +- [#11203](https://github.com/emberjs/ember.js/pull/11203) [BUGFIX] Ensure components for void tagNames do not have childNodes. +- [#11205](https://github.com/emberjs/ember.js/pull/11205) [BUGFIX] Ensure `Ember.get` works on empty string paths. +- [#11220](https://github.com/emberjs/ember.js/pull/11220) [BUGFIX] Fix issue with `Ember.computed.sort` where array observers were not properly detached. +- [#11222](https://github.com/emberjs/ember.js/pull/11222) [BUGFIX] Only attempt to lookup components with a dash. +- [#11227](https://github.com/emberjs/ember.js/pull/11227) [BUGFIX] Ensure `role` is properly applied to views if `ariaRole` attribute is present. +- [#11228](https://github.com/emberjs/ember.js/pull/11228) [BUGFIX] Fix `{{each}}` with `itemViewClass` specified `tagName`. +- [#11231](https://github.com/emberjs/ember.js/pull/11231) [BUGFIX] Fix `{{each}}` with `itemViewClass` and `{{else}}`. +- [#11234](https://github.com/emberjs/ember.js/pull/11234) [BUGFIX] Fix `{{each item in model itemViewClass="..."}}`. +- [#11235](https://github.com/emberjs/ember.js/pull/11235) [BUGFIX] Properly handle `isVisible` as a computed property. +- [#11242](https://github.com/emberjs/ember.js/pull/11242) [BUGFIX] Use the proper value for `options.data.view` with Handlebars compat helpers. +- [#11252](https://github.com/emberjs/ember.js/pull/11253) [BUGFIX] Ensure `instanceInitializers` are called with the proper arguments when calling `App.reset`. +- [#11257](https://github.com/emberjs/ember.js/pull/11257) [BUGFIX] Fix (and deprecate) `{{input on="..." action="..."}}`. +- [#11260](https://github.com/emberjs/ember.js/pull/11260) [BUGFIX] Ensure that passing an array argument to `(action` helper is handled properly. +- [#11261](https://github.com/emberjs/ember.js/pull/11261) Add helpful assertion when exporting the wrong type of factory (for Routes, Components, Services, and Views). +- [#11266](https://github.com/emberjs/ember.js/pull/11266) [BUGFIX] Ensure `parentView` includes yielding component. +- [#11267](https://github.com/emberjs/ember.js/pull/11267) Disable angle bracket components. See [#11267](https://github.com/emberjs/ember.js/pull/11267) and [emberjs/rfcs#60](https://github.com/emberjs/rfcs/pull/60) for more details. +- [#3852](https://github.com/emberjs/ember.js/pull/3852) [BREAKING BUGFIX] Do not assume null Ember.get targets always refer to a global +- [#10501](https://github.com/emberjs/ember.js/pull/10501) Implement Glimmer Engine. +- [#11029](https://github.com/emberjs/ember.js/pull/11029) Allow bound outlet names. +- [#11035](https://github.com/emberjs/ember.js/pull/11035) {{#with}} helper should not render if passed variable is falsey. +- [#11104](https://github.com/emberjs/ember.js/pull/11104) / [#10501](https://github.com/emberjs/ember.js/pull/10501) Remove support for non-HTMLBars templates. +- [#11116](https://github.com/emberjs/ember.js/pull/11116) / [emberjs/rfcs#50](https://github.com/emberjs/rfcs/pull/50) [FEATURE ember-routing-htmlbars-improved-actions]. +- [#11028](https://github.com/emberjs/ember.js/pull/11028) Add positional parameter support to components. +- [#11084](https://github.com/emberjs/ember.js/pull/11084) Enable {{yield to="inverse"}} in components. +- [#11141](https://github.com/emberjs/ember.js/pull/11141) Implement angle-bracket components. + ### 1.12.0 (May 13, 2015) - [#10874](https://github.com/emberjs/ember.js/pull/10874) Include all files in jspm package.
false
Other
emberjs
ember.js
177733b42d7aef11a7b63f684d3194ddeb6e1447.json
Remove invalid usage of run.later.
packages/ember-htmlbars/tests/integration/will-destroy-element-hook-test.js
@@ -14,7 +14,6 @@ QUnit.module('ember-htmlbars: destroy-element-hook tests', { }); QUnit.test('willDestroyElement is only called once when a component leaves scope', function(assert) { - var done = assert.async(); var innerChild, innerChildDestroyed; component = Component.create({ @@ -47,14 +46,12 @@ QUnit.test('willDestroyElement is only called once when a component leaves scope assert.equal(component.$().text(), 'Truthy', 'precond - truthy template is displayed'); assert.equal(component.get('childViews.length'), 1); - run.later(function() { + run(function() { set(component, 'switch', false); + }); - run.later(function() { - assert.equal(innerChild.get('isDestroyed'), true, 'the innerChild has been destroyed'); - assert.equal(component.$().text(), '', 'truthy template is removed'); - - done(); - }); + run(function() { + assert.equal(innerChild.get('isDestroyed'), true, 'the innerChild has been destroyed'); + assert.equal(component.$().text(), '', 'truthy template is removed'); }); });
false
Other
emberjs
ember.js
5eae4d03254f3fb6871cd40a5360381520b77495.json
Remove extra space
packages/ember-views/lib/views/text_field.js
@@ -2,7 +2,7 @@ @module ember @submodule ember-views */ -import { computed } from "ember-metal/computed"; +import { computed } from "ember-metal/computed"; import environment from "ember-metal/environment"; import create from "ember-metal/platform/create"; import Component from "ember-views/views/component";
false
Other
emberjs
ember.js
ac846c375b44089c6e0d9d6c3cb953ced5c30d7d.json
Destroy components when changed on re-render Most of the infrastructure around components assumes they are static (e.g. <my-component> cannot become a <foo-component> after it is rendered). As such, there were some holes in destruction for the one dynamic case (the {{component}} helper). This commit detects when the underlying component has changed and ensures that the component is scheduled for destruction before the new component is swapped in. It also fixes a similar issue with the view helper.
packages/ember-htmlbars/lib/keywords/component.js
@@ -7,6 +7,10 @@ export default { }, render(morph, ...rest) { + if (morph.state.manager) { + morph.state.manager.destroy(); + } + // Force the component hook to treat this as a first-time render, // because normal components (`<foo-bar>`) cannot change at runtime, // but the `{{component}}` helper can.
true
Other
emberjs
ember.js
ac846c375b44089c6e0d9d6c3cb953ced5c30d7d.json
Destroy components when changed on re-render Most of the infrastructure around components assumes they are static (e.g. <my-component> cannot become a <foo-component> after it is rendered). As such, there were some holes in destruction for the one dynamic case (the {{component}} helper). This commit detects when the underlying component has changed and ensures that the component is scheduled for destruction before the new component is swapped in. It also fixes a similar issue with the view helper.
packages/ember-htmlbars/lib/keywords/view.js
@@ -70,6 +70,11 @@ export default { options.createOptions._targetObject = node.state.targetObject; } + if (state.manager) { + state.manager.destroy(); + state.manager = null; + } + var nodeManager = ViewNodeManager.create(node, env, hash, options, parentView, null, scope, template); state.manager = nodeManager;
true
Other
emberjs
ember.js
ac846c375b44089c6e0d9d6c3cb953ced5c30d7d.json
Destroy components when changed on re-render Most of the infrastructure around components assumes they are static (e.g. <my-component> cannot become a <foo-component> after it is rendered). As such, there were some holes in destruction for the one dynamic case (the {{component}} helper). This commit detects when the underlying component has changed and ensures that the component is scheduled for destruction before the new component is swapped in. It also fixes a similar issue with the view helper.
packages/ember-htmlbars/lib/node-managers/component-node-manager.js
@@ -264,6 +264,15 @@ ComponentNodeManager.prototype.rerender = function(_env, attrs, visitor) { }, this); }; +ComponentNodeManager.prototype.destroy = function() { + let component = this.component; + + // Clear component's render node. Normally this gets cleared + // during view destruction, but in this case we're re-assigning the + // node to a different view and it will get cleaned up automatically. + component._renderNode = null; + component.destroy(); +}; export function createComponent(_component, isAngleBracket, _props, renderNode, env, attrs = {}) { let props = assign({}, _props); @@ -298,9 +307,6 @@ export function createComponent(_component, isAngleBracket, _props, renderNode, } component._renderNode = renderNode; - if (renderNode.emberView && renderNode.emberView !== component) { - throw new Error('Need to clean up this view before blindly reassigning.'); - } renderNode.emberView = component; return component; }
true
Other
emberjs
ember.js
ac846c375b44089c6e0d9d6c3cb953ced5c30d7d.json
Destroy components when changed on re-render Most of the infrastructure around components assumes they are static (e.g. <my-component> cannot become a <foo-component> after it is rendered). As such, there were some holes in destruction for the one dynamic case (the {{component}} helper). This commit detects when the underlying component has changed and ensures that the component is scheduled for destruction before the new component is swapped in. It also fixes a similar issue with the view helper.
packages/ember-htmlbars/lib/node-managers/view-node-manager.js
@@ -149,6 +149,10 @@ ViewNodeManager.prototype.rerender = function(env, attrs, visitor) { }, this); }; +ViewNodeManager.prototype.destroy = function() { + this.component.destroy(); +}; + function getTemplate(componentOrView) { return componentOrView.isComponent ? get(componentOrView, '_template') : get(componentOrView, 'template'); } @@ -192,9 +196,6 @@ export function createOrUpdateComponent(component, options, createOptions, rende component._renderNode = renderNode; - if (renderNode.emberView && renderNode.emberView !== component) { - throw new Error('Need to clean up this view before blindly reassigning.'); - } renderNode.emberView = component; return component; }
true
Other
emberjs
ember.js
e271685e96f0137e3042a480c33c23896b483acc.json
Make Ember.Checkbox extend from Ember.Component
packages/ember-views/lib/views/checkbox.js
@@ -1,6 +1,6 @@ import { get } from "ember-metal/property_get"; import { set } from "ember-metal/property_set"; -import View from "ember-views/views/view"; +import EmberComponent from "ember-views/views/component"; /** @module ember @@ -29,11 +29,10 @@ import View from "ember-views/views/view"; @class Checkbox @namespace Ember - @extends Ember.View + @extends Ember.Component @public */ -// 2.0TODO: Subclass Component rather than View -export default View.extend({ +export default EmberComponent.extend({ instrumentDisplay: '{{input type="checkbox"}}', classNames: ['ember-checkbox'],
true
Other
emberjs
ember.js
e271685e96f0137e3042a480c33c23896b483acc.json
Make Ember.Checkbox extend from Ember.Component
packages/ember-views/tests/views/checkbox_test.js
@@ -11,12 +11,11 @@ function set(obj, key, value) { function append() { run(function() { - checkboxView.appendTo('#qunit-fixture'); + checkboxComponent.appendTo('#qunit-fixture'); }); } - -var checkboxView, dispatcher; +var checkboxComponent, dispatcher; QUnit.module("Ember.Checkbox", { setup() { @@ -27,116 +26,116 @@ QUnit.module("Ember.Checkbox", { teardown() { run(function() { dispatcher.destroy(); - checkboxView.destroy(); + checkboxComponent.destroy(); }); } }); QUnit.test("should begin disabled if the disabled attribute is true", function() { - checkboxView = Checkbox.create({}); + checkboxComponent = Checkbox.create({}); - checkboxView.set('disabled', true); + checkboxComponent.set('disabled', true); append(); - ok(checkboxView.$().is(":disabled")); + ok(checkboxComponent.$().is(":disabled")); }); QUnit.test("should become disabled if the disabled attribute is changed", function() { - checkboxView = Checkbox.create({}); + checkboxComponent = Checkbox.create({}); append(); - ok(checkboxView.$().is(":not(:disabled)")); + ok(checkboxComponent.$().is(":not(:disabled)")); - run(function() { checkboxView.set('disabled', true); }); - ok(checkboxView.$().is(":disabled")); + run(function() { checkboxComponent.set('disabled', true); }); + ok(checkboxComponent.$().is(":disabled")); - run(function() { checkboxView.set('disabled', false); }); - ok(checkboxView.$().is(":not(:disabled)")); + run(function() { checkboxComponent.set('disabled', false); }); + ok(checkboxComponent.$().is(":not(:disabled)")); }); QUnit.test("should begin indeterminate if the indeterminate attribute is true", function() { - checkboxView = Checkbox.create({}); + checkboxComponent = Checkbox.create({}); - checkboxView.set('indeterminate', true); + checkboxComponent.set('indeterminate', true); append(); - equal(checkboxView.$().prop('indeterminate'), true, "Checkbox should be indeterminate"); + equal(checkboxComponent.$().prop('indeterminate'), true, "Checkbox should be indeterminate"); }); QUnit.test("should become indeterminate if the indeterminate attribute is changed", function() { - checkboxView = Checkbox.create({}); + checkboxComponent = Checkbox.create({}); append(); - equal(checkboxView.$().prop('indeterminate'), false, "Checkbox should not be indeterminate"); + equal(checkboxComponent.$().prop('indeterminate'), false, "Checkbox should not be indeterminate"); - run(function() { checkboxView.set('indeterminate', true); }); - equal(checkboxView.$().prop('indeterminate'), true, "Checkbox should be indeterminate"); + run(function() { checkboxComponent.set('indeterminate', true); }); + equal(checkboxComponent.$().prop('indeterminate'), true, "Checkbox should be indeterminate"); - run(function() { checkboxView.set('indeterminate', false); }); - equal(checkboxView.$().prop('indeterminate'), false, "Checkbox should not be indeterminate"); + run(function() { checkboxComponent.set('indeterminate', false); }); + equal(checkboxComponent.$().prop('indeterminate'), false, "Checkbox should not be indeterminate"); }); QUnit.test("should support the tabindex property", function() { - checkboxView = Checkbox.create({}); + checkboxComponent = Checkbox.create({}); - run(function() { checkboxView.set('tabindex', 6); }); + run(function() { checkboxComponent.set('tabindex', 6); }); append(); - equal(checkboxView.$().prop('tabindex'), '6', 'the initial checkbox tabindex is set in the DOM'); + equal(checkboxComponent.$().prop('tabindex'), '6', 'the initial checkbox tabindex is set in the DOM'); - run(function() { checkboxView.set('tabindex', 3); }); - equal(checkboxView.$().prop('tabindex'), '3', 'the checkbox tabindex changes when it is changed in the view'); + run(function() { checkboxComponent.set('tabindex', 3); }); + equal(checkboxComponent.$().prop('tabindex'), '3', 'the checkbox tabindex changes when it is changed in the component'); }); QUnit.test("checkbox name is updated when setting name property of view", function() { - checkboxView = Checkbox.create({}); + checkboxComponent = Checkbox.create({}); - run(function() { checkboxView.set('name', 'foo'); }); + run(function() { checkboxComponent.set('name', 'foo'); }); append(); - equal(checkboxView.$().attr('name'), "foo", "renders checkbox with the name"); + equal(checkboxComponent.$().attr('name'), "foo", "renders checkbox with the name"); - run(function() { checkboxView.set('name', 'bar'); }); + run(function() { checkboxComponent.set('name', 'bar'); }); - equal(checkboxView.$().attr('name'), "bar", "updates checkbox after name changes"); + equal(checkboxComponent.$().attr('name'), "bar", "updates checkbox after name changes"); }); QUnit.test("checked property mirrors input value", function() { - checkboxView = Checkbox.create({}); - run(function() { checkboxView.append(); }); + checkboxComponent = Checkbox.create({}); + run(function() { checkboxComponent.append(); }); - equal(get(checkboxView, 'checked'), false, "initially starts with a false value"); - equal(!!checkboxView.$().prop('checked'), false, "the initial checked property is false"); + equal(get(checkboxComponent, 'checked'), false, "initially starts with a false value"); + equal(!!checkboxComponent.$().prop('checked'), false, "the initial checked property is false"); - set(checkboxView, 'checked', true); + set(checkboxComponent, 'checked', true); - equal(checkboxView.$().prop('checked'), true, "changing the value property changes the DOM"); + equal(checkboxComponent.$().prop('checked'), true, "changing the value property changes the DOM"); - run(function() { checkboxView.remove(); }); - run(function() { checkboxView.append(); }); + run(function() { checkboxComponent.remove(); }); + run(function() { checkboxComponent.append(); }); - equal(checkboxView.$().prop('checked'), true, "changing the value property changes the DOM"); + equal(checkboxComponent.$().prop('checked'), true, "changing the value property changes the DOM"); - run(function() { checkboxView.remove(); }); - run(function() { set(checkboxView, 'checked', false); }); - run(function() { checkboxView.append(); }); + run(function() { checkboxComponent.remove(); }); + run(function() { set(checkboxComponent, 'checked', false); }); + run(function() { checkboxComponent.append(); }); - equal(checkboxView.$().prop('checked'), false, "changing the value property changes the DOM"); + equal(checkboxComponent.$().prop('checked'), false, "changing the value property changes the DOM"); }); QUnit.test("checking the checkbox updates the value", function() { - checkboxView = Checkbox.create({ checked: true }); + checkboxComponent = Checkbox.create({ checked: true }); append(); - equal(get(checkboxView, 'checked'), true, "precond - initially starts with a true value"); - equal(!!checkboxView.$().prop('checked'), true, "precond - the initial checked property is true"); + equal(get(checkboxComponent, 'checked'), true, "precond - initially starts with a true value"); + equal(!!checkboxComponent.$().prop('checked'), true, "precond - the initial checked property is true"); // IE fires 'change' event on blur. - checkboxView.$()[0].focus(); - checkboxView.$()[0].click(); - checkboxView.$()[0].blur(); + checkboxComponent.$()[0].focus(); + checkboxComponent.$()[0].click(); + checkboxComponent.$()[0].blur(); - equal(!!checkboxView.$().prop('checked'), false, "after clicking a checkbox, the checked property changed"); - equal(get(checkboxView, 'checked'), false, "changing the checkbox causes the view's value to get updated"); + equal(!!checkboxComponent.$().prop('checked'), false, "after clicking a checkbox, the checked property changed"); + equal(get(checkboxComponent, 'checked'), false, "changing the checkbox causes the view's value to get updated"); });
true
Other
emberjs
ember.js
1c10d2fb0bfe4a0e9918fb597acf95fe620156ed.json
Add test for deprecation message
packages/ember-routing-views/lib/views/link.js
@@ -33,7 +33,7 @@ if (isEnabled('ember-routing-transitioning-classes')) { @class LinkComponent @namespace Ember - @extends Ember.View + @extends Ember.Component @see {Handlebars.helpers.link-to} @private **/
true
Other
emberjs
ember.js
1c10d2fb0bfe4a0e9918fb597acf95fe620156ed.json
Add test for deprecation message
packages/ember-routing-views/tests/main_test.js
@@ -6,3 +6,8 @@ QUnit.test("exports correctly", function() { ok(Ember.LinkComponent, "LinkComponent is exported correctly"); ok(Ember.OutletView, "OutletView is exported correctly"); }); + +QUnit.test("Ember.LinkView is deprecated", function() { + expectDeprecation(/Ember.LinkView is deprecated. Please use Ember.LinkComponent/); + Ember.LinkView.create(); +});
true
Other
emberjs
ember.js
796aff2146d0573f4240bec294201b33ab9a9ad9.json
Return the setter values instead of this
packages/ember-metal/lib/set_properties.js
@@ -20,11 +20,11 @@ import keys from "ember-metal/keys"; @method setProperties @param obj @param {Object} properties - @return obj + @return properties @public */ export default function setProperties(obj, properties) { - if (!properties || typeof properties !== "object") { return obj; } + if (!properties || typeof properties !== "object") { return properties; } changeProperties(function() { var props = keys(properties); var propertyName; @@ -35,5 +35,5 @@ export default function setProperties(obj, properties) { set(obj, propertyName, properties[propertyName]); } }); - return obj; + return properties; }
true
Other
emberjs
ember.js
796aff2146d0573f4240bec294201b33ab9a9ad9.json
Return the setter values instead of this
packages/ember-runtime/lib/mixins/observable.js
@@ -460,8 +460,7 @@ export default Mixin.create({ incrementProperty(keyName, increment) { if (isNone(increment)) { increment = 1; } Ember.assert("Must pass a numeric value to incrementProperty", (!isNaN(parseFloat(increment)) && isFinite(increment))); - set(this, keyName, (parseFloat(get(this, keyName)) || 0) + increment); - return get(this, keyName); + return set(this, keyName, (parseFloat(get(this, keyName)) || 0) + increment); }, /** @@ -481,8 +480,7 @@ export default Mixin.create({ decrementProperty(keyName, decrement) { if (isNone(decrement)) { decrement = 1; } Ember.assert("Must pass a numeric value to decrementProperty", (!isNaN(parseFloat(decrement)) && isFinite(decrement))); - set(this, keyName, (get(this, keyName) || 0) - decrement); - return get(this, keyName); + return set(this, keyName, (get(this, keyName) || 0) - decrement); }, /** @@ -499,8 +497,7 @@ export default Mixin.create({ @public */ toggleProperty(keyName) { - set(this, keyName, !get(this, keyName)); - return get(this, keyName); + return set(this, keyName, !get(this, keyName)); }, /**
true
Other
emberjs
ember.js
a5e5ad6917ee2f091f826aa5996be1c4d0c10db7.json
Fix helper export, add test
packages/ember-htmlbars/lib/main.js
@@ -72,7 +72,7 @@ Ember.HTMLBars = { DOMHelper }; -if (Ember.FEATURES.isEnabled('ember-htmlbars-helpers')) { +if (Ember.FEATURES.isEnabled('ember-htmlbars-helper')) { Helper.helper = makeHelper; Ember.Helper = Helper; }
true
Other
emberjs
ember.js
a5e5ad6917ee2f091f826aa5996be1c4d0c10db7.json
Fix helper export, add test
packages/ember/tests/global-api-test.js
@@ -10,3 +10,7 @@ function confirmExport(property) { confirmExport('Ember.DefaultResolver'); confirmExport('Ember.generateController'); +if (Ember.FEATURES.isEnabled('ember-htmlbars-helper')) { + confirmExport('Ember.Helper'); + confirmExport('Ember.Helper.helper'); +}
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
package.json
@@ -23,7 +23,7 @@ "express": "^4.5.0", "github": "^0.2.3", "glob": "~4.3.2", - "htmlbars": "0.13.25", + "htmlbars": "0.13.28", "qunit-extras": "^1.3.0", "qunitjs": "^1.16.0", "route-recognizer": "0.1.5",
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
packages/ember-application/lib/system/application.js
@@ -1016,7 +1016,6 @@ Application.reopenClass({ registry.optionsForType('component', { singleton: false }); registry.optionsForType('view', { singleton: false }); registry.optionsForType('template', { instantiate: false }); - registry.optionsForType('helper', { instantiate: false }); registry.register('application:main', namespace, { instantiate: false });
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
packages/ember-application/lib/system/resolver.js
@@ -15,6 +15,7 @@ import EmberObject from 'ember-runtime/system/object'; import Namespace from 'ember-runtime/system/namespace'; import helpers from 'ember-htmlbars/helpers'; import validateType from 'ember-application/utils/validate-type'; +import HandlebarsCompatibleHelper from "ember-htmlbars/compat/helper"; export var Resolver = EmberObject.extend({ /* @@ -374,7 +375,11 @@ export default EmberObject.extend({ @public */ resolveHelper(parsedName) { - return this.resolveOther(parsedName) || helpers[parsedName.fullNameWithoutType]; + var resolved = this.resolveOther(parsedName) || helpers[parsedName.fullNameWithoutType]; + if (resolved && !resolved.isHelperFactory && !resolved.isHelperInstance && !resolved.isHTMLBars && typeof resolved === 'function') { + resolved = new HandlebarsCompatibleHelper(resolved); + } + return resolved; }, /** Look up the specified object (from parsedName) on the appropriate
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
packages/ember-application/tests/system/dependency_injection/default_resolver_test.js
@@ -9,6 +9,11 @@ import Service from "ember-runtime/system/service"; import EmberObject from "ember-runtime/system/object"; import Namespace from "ember-runtime/system/namespace"; import Application from "ember-application/system/application"; +import Helper from "ember-htmlbars/helper"; +import HandlebarsCompatibleHelper from "ember-htmlbars/compat/helper"; +import makeHandlebarsBoundHelper from "ember-htmlbars/compat/make-bound-helper"; +import makeViewHelper from "ember-htmlbars/system/make-view-helper"; +import makeHTMLBarsBoundHelper from "ember-htmlbars/system/make_bound_helper"; import { registerHelper } from "ember-htmlbars/helpers"; @@ -102,12 +107,48 @@ QUnit.test("the default resolver resolves helpers", function() { }); QUnit.test("the default resolver resolves container-registered helpers", function() { - function gooresolvertestHelper() { return 'GOO'; } - function gooGazResolverTestHelper() { return 'GAZ'; } - application.register('helper:gooresolvertest', gooresolvertestHelper); - application.register('helper:goo-baz-resolver-test', gooGazResolverTestHelper); - equal(gooresolvertestHelper, locator.lookup('helper:gooresolvertest'), "looks up gooresolvertest helper"); - equal(gooGazResolverTestHelper, locator.lookup('helper:goo-baz-resolver-test'), "looks up gooGazResolverTestHelper helper"); + let shorthandHelper = Helper.helper(function() {}); + let helper = Helper.extend(); + + application.register('helper:shorthand', shorthandHelper); + application.register('helper:complete', helper); + + let lookedUpShorthandHelper = locator.lookupFactory('helper:shorthand'); + ok(lookedUpShorthandHelper.isHelperInstance, 'shorthand helper isHelper'); + + let 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() { + let ShorthandHelper = Helper.helper(function() {}); + let CompleteHelper = Helper.extend(); + let LegacyBareFunctionHelper = function() {}; + let LegacyHandlebarsBoundHelper = makeHandlebarsBoundHelper(function() {}); + let LegacyHTMLBarsBoundHelper = makeHTMLBarsBoundHelper(function() {}); + let ViewHelper = makeViewHelper(function() {}); + + application.ShorthandHelper = ShorthandHelper; + application.CompleteHelper = CompleteHelper; + application.LegacyBareFunctionHelper = LegacyBareFunctionHelper; + application.LegacyHandlebarsBoundHelper = LegacyHandlebarsBoundHelper; + application.LegacyHtmlBarsBoundHelper = LegacyHTMLBarsBoundHelper; // Must use lowered "tml" in "HTMLBars" for resolver to find this + application.ViewHelper = ViewHelper; + + let resolvedShorthand = registry.resolve('helper:shorthand'); + let resolvedComplete = registry.resolve('helper:complete'); + let resolvedLegacy = registry.resolve('helper:legacy-bare-function'); + let resolvedLegacyHandlebars = registry.resolve('helper:legacy-handlebars-bound'); + let resolvedLegacyHTMLBars = registry.resolve('helper:legacy-html-bars-bound'); + let resolvedView = registry.resolve('helper:view'); + + equal(resolvedShorthand, ShorthandHelper, 'resolve fetches the shorthand helper factory'); + equal(resolvedComplete, CompleteHelper, 'resolve fetches the complete helper factory'); + ok(resolvedLegacy instanceof HandlebarsCompatibleHelper, 'legacy function helper is wrapped in HandlebarsCompatibleHelper'); + equal(resolvedView, ViewHelper, 'resolves view helper'); + equal(resolvedLegacyHTMLBars, LegacyHTMLBarsBoundHelper, 'resolves legacy HTMLBars bound helper'); + equal(resolvedLegacyHandlebars, LegacyHandlebarsBoundHelper, 'resolves legacy Handlebars bound helper'); }); QUnit.test("the default resolver throws an error if the fullName to resolve is invalid", function() {
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
packages/ember-htmlbars/lib/helper.js
@@ -0,0 +1,25 @@ +import Object from "ember-runtime/system/object"; + +// Ember.Helper.extend({ compute(params, hash) {} }); +var Helper = Object.extend({ + isHelper: true, + recompute() { + this._stream.notify(); + } +}); + +Helper.reopenClass({ + isHelperFactory: true +}); + +// Ember.Helper.helper(function(params, hash) {}); +export function helper(helperFn) { + return { + isHelperInstance: true, + compute: helperFn + }; +} + +Helper.helper = helper; + +export default Helper;
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
packages/ember-htmlbars/lib/hooks/element.js
@@ -5,6 +5,7 @@ import { findHelper } from "ember-htmlbars/system/lookup-helper"; import { handleRedirect } from "htmlbars-runtime/hooks"; +import { buildHelperStream } from "ember-htmlbars/system/invoke-helper"; var fakeElement; @@ -32,7 +33,8 @@ export default function emberElement(morph, env, scope, path, params, hash, visi var result; var helper = findHelper(path, scope.self, env); if (helper) { - result = env.hooks.invokeHelper(null, env, scope, null, params, hash, helper, { element: morph.element }).value; + var helperStream = buildHelperStream(helper, params, hash, { element: morph.element }, env, scope); + result = helperStream.value(); } else { result = env.hooks.get(env, scope, path); }
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
packages/ember-htmlbars/lib/hooks/has-helper.js
@@ -1,5 +1,17 @@ -import { findHelper } from "ember-htmlbars/system/lookup-helper"; +import { validateLazyHelperName } from "ember-htmlbars/system/lookup-helper"; export default function hasHelperHook(env, scope, helperName) { - return !!findHelper(helperName, scope.self, env); + if (env.helpers[helperName]) { + return true; + } + + var container = env.container; + if (validateLazyHelperName(helperName, container, env.hooks.keywords)) { + var containerName = 'helper:' + helperName; + if (container._registry.has(containerName)) { + return true; + } + } + + return false; }
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
packages/ember-htmlbars/lib/hooks/invoke-helper.js
@@ -1,43 +1,24 @@ import Ember from 'ember-metal/core'; // Ember.assert -import getValue from "ember-htmlbars/hooks/get-value"; +import { buildHelperStream } from "ember-htmlbars/system/invoke-helper"; +export default function invokeHelper(morph, env, scope, visitor, params, hash, helper, templates, context) { - -export default function invokeHelper(morph, env, scope, visitor, _params, _hash, helper, templates, context) { - var params, hash; - - if (typeof helper === 'function') { - params = getArrayValues(_params); - hash = getHashValues(_hash); - return { value: helper.call(context, params, hash, templates) }; - } else if (helper.isLegacyViewHelper) { + if (helper.isLegacyViewHelper) { Ember.assert("You can only pass attributes (such as name=value) not bare " + - "values to a helper for a View found in '" + helper.viewClass + "'", _params.length === 0); + "values to a helper for a View found in '" + helper.viewClass + "'", params.length === 0); - env.hooks.keyword('view', morph, env, scope, [helper.viewClass], _hash, templates.template.raw, null, visitor); + env.hooks.keyword('view', morph, env, scope, [helper.viewClass], hash, templates.template.raw, null, visitor); + // Opts into a special mode for view helpers return { handled: true }; - } else if (helper && helper.helperFunction) { - var helperFunc = helper.helperFunction; - return { value: helperFunc.call({}, _params, _hash, templates, env, scope) }; - } -} - -// We don't want to leak mutable cells into helpers, which -// are pure functions that can only work with values. -function getArrayValues(params) { - let out = []; - for (let i=0, l=params.length; i<l; i++) { - out.push(getValue(params[i])); } - return out; -} + var helperStream = buildHelperStream(helper, params, hash, templates, env, scope, context); -function getHashValues(hash) { - let out = {}; - for (let prop in hash) { - out[prop] = getValue(hash[prop]); + // Ember.Helper helpers are pure values, thus linkable + if (helperStream.linkable) { + return { link: true, value: helperStream }; } - return out; + // Legacy helpers are not linkable, they must run every rerender + return { value: helperStream.value() }; }
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
packages/ember-htmlbars/lib/hooks/subexpr.js
@@ -4,12 +4,8 @@ */ import lookupHelper from "ember-htmlbars/system/lookup-helper"; -import merge from "ember-metal/merge"; -import Stream from "ember-metal/streams/stream"; -import create from "ember-metal/platform/create"; +import { buildHelperStream } from "ember-htmlbars/system/invoke-helper"; import { - readArray, - readHash, labelsFor, labelFor } from "ember-metal/streams/utils"; @@ -22,15 +18,20 @@ export default function subexpr(env, scope, helperName, params, hash) { return keyword(null, env, scope, params, hash, null, null); } + var label = labelForSubexpr(params, hash, helperName); var helper = lookupHelper(helperName, scope.self, env); - var invoker = function(params, hash) { - return env.hooks.invokeHelper(null, env, scope, null, params, hash, helper, { template: {}, inverse: {} }, undefined).value; - }; - //Ember.assert("A helper named '"+helperName+"' could not be found", typeof helper === 'function'); + var helperStream = buildHelperStream(helper, params, hash, { template: {}, inverse: {} }, env, scope, label); - var label = labelForSubexpr(params, hash, helperName); - return new SubexprStream(params, hash, invoker, label); + for (var i = 0, l = params.length; i < l; i++) { + helperStream.addDependency(params[i]); + } + + for (var key in hash) { + helperStream.addDependency(hash[key]); + } + + return helperStream; } function labelForSubexpr(params, hash, helperName) { @@ -57,26 +58,3 @@ function labelsForHash(hash) { return out.join(" "); } - -function SubexprStream(params, hash, helper, label) { - this.init(label); - this.params = params; - this.hash = hash; - this.helper = helper; - - for (var i = 0, l = params.length; i < l; i++) { - this.addDependency(params[i]); - } - - for (var key in hash) { - this.addDependency(hash[key]); - } -} - -SubexprStream.prototype = create(Stream.prototype); - -merge(SubexprStream.prototype, { - compute() { - return this.helper(readArray(this.params), readHash(this.hash)); - } -});
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
packages/ember-htmlbars/lib/main.js
@@ -31,6 +31,7 @@ import legacyEachWithKeywordHelper from "ember-htmlbars/helpers/-legacy-each-wit import getHelper from "ember-htmlbars/helpers/-get"; import htmlSafeHelper from "ember-htmlbars/helpers/-html-safe"; import DOMHelper from "ember-htmlbars/system/dom-helper"; +import Helper from "ember-htmlbars/helper"; // importing adds template bootstrapping // initializer to enable embedded templates @@ -70,3 +71,5 @@ Ember.HTMLBars = { registerPlugin: registerPlugin, DOMHelper }; + +Ember.Helper = Helper;
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
packages/ember-htmlbars/lib/streams/built-in-helper.js
@@ -0,0 +1,27 @@ +import Stream from "ember-metal/streams/stream"; +import create from "ember-metal/platform/create"; +import merge from "ember-metal/merge"; +import { + getArrayValues, + getHashValues +} from "ember-htmlbars/streams/utils"; + +export default function BuiltInHelperStream(helper, params, hash, templates, env, scope, context, label) { + this.init(label); + this.helper = helper; + this.params = params; + this.templates = templates; + this.env = env; + this.scope = scope; + this.hash = hash; + this.context = context; +} + +BuiltInHelperStream.prototype = create(Stream.prototype); + +merge(BuiltInHelperStream.prototype, { + compute() { + // Using call and undefined is probably not needed, these are only internal + return this.helper.call(this.context, getArrayValues(this.params), getHashValues(this.hash), this.templates, this.env, this.scope); + } +});
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
packages/ember-htmlbars/lib/streams/compat-helper.js
@@ -0,0 +1,22 @@ +import Stream from "ember-metal/streams/stream"; +import create from "ember-metal/platform/create"; +import merge from "ember-metal/merge"; + +export default function CompatHelperStream(helper, params, hash, templates, env, scope, label) { + this.init(label); + this.helper = helper.helperFunction; + this.params = params; + this.templates = templates; + this.env = env; + this.scope = scope; + this.hash = hash; +} + +CompatHelperStream.prototype = create(Stream.prototype); + +merge(CompatHelperStream.prototype, { + compute() { + // Using call and undefined is probably not needed, these are only internal + return this.helper.call(undefined, this.params, this.hash, this.templates, this.env, this.scope); + } +});
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
packages/ember-htmlbars/lib/streams/helper-factory.js
@@ -0,0 +1,35 @@ +import Stream from "ember-metal/streams/stream"; +import create from "ember-metal/platform/create"; +import merge from "ember-metal/merge"; +import { + getArrayValues, + getHashValues +} from "ember-htmlbars/streams/utils"; + +export default function HelperFactoryStream(helperFactory, params, hash, label) { + this.init(label); + this.helperFactory = helperFactory; + this.params = params; + this.hash = hash; + this.linkable = true; + this.helper = null; +} + +HelperFactoryStream.prototype = create(Stream.prototype); + +merge(HelperFactoryStream.prototype, { + compute() { + if (!this.helper) { + this.helper = this.helperFactory.create({ _stream: this }); + } + return this.helper.compute(getArrayValues(this.params), getHashValues(this.hash)); + }, + deactivate() { + this.super$deactivate(); + if (this.helper) { + this.helper.destroy(); + this.helper = null; + } + }, + super$deactivate: HelperFactoryStream.prototype.deactivate +});
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
packages/ember-htmlbars/lib/streams/helper-instance.js
@@ -0,0 +1,23 @@ +import Stream from "ember-metal/streams/stream"; +import create from "ember-metal/platform/create"; +import merge from "ember-metal/merge"; +import { + getArrayValues, + getHashValues +} from "ember-htmlbars/streams/utils"; + +export default function HelperInstanceStream(helper, params, hash, label) { + this.init(label); + this.helper = helper; + this.params = params; + this.hash = hash; + this.linkable = true; +} + +HelperInstanceStream.prototype = create(Stream.prototype); + +merge(HelperInstanceStream.prototype, { + compute() { + return this.helper.compute(getArrayValues(this.params), getHashValues(this.hash)); + } +});
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
packages/ember-htmlbars/lib/streams/utils.js
@@ -0,0 +1,21 @@ +import getValue from "ember-htmlbars/hooks/get-value"; + +// We don't want to leak mutable cells into helpers, which +// are pure functions that can only work with values. +export function getArrayValues(params) { + let out = []; + for (let i=0, l=params.length; i<l; i++) { + out.push(getValue(params[i])); + } + + return out; +} + +export function getHashValues(hash) { + let out = {}; + for (let prop in hash) { + out[prop] = getValue(hash[prop]); + } + + return out; +}
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
packages/ember-htmlbars/lib/system/invoke-helper.js
@@ -0,0 +1,17 @@ +import HelperInstanceStream from "ember-htmlbars/streams/helper-instance"; +import HelperFactoryStream from "ember-htmlbars/streams/helper-factory"; +import BuiltInHelperStream from "ember-htmlbars/streams/built-in-helper"; +import CompatHelperStream from "ember-htmlbars/streams/compat-helper"; + +export function buildHelperStream(helper, params, hash, templates, env, scope, context, label) { + Ember.assert("Helpers may not be used in the block form, for example {{#my-helper}}{{/my-helper}}. Please use a component, or alternatively use the helper in combination with a built-in Ember helper, for example {{#if (my-helper)}}{{/if}}.", !helper.isHelperInstance || !helper.isHelperFactory && !templates.template.meta); + if (helper.isHelperFactory) { + return new HelperFactoryStream(helper, params, hash, label); + } else if (helper.isHelperInstance) { + return new HelperInstanceStream(helper, params, hash, label); + } else if (helper.helperFunction) { + return new CompatHelperStream(helper, params, hash, templates, env, scope, label); + } else { + return new BuiltInHelperStream(helper, params, hash, templates, env, scope, context, label); + } +}
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
packages/ember-htmlbars/lib/system/lookup-helper.js
@@ -5,13 +5,15 @@ import Ember from "ember-metal/core"; import Cache from "ember-metal/cache"; -import makeViewHelper from "ember-htmlbars/system/make-view-helper"; -import HandlebarsCompatibleHelper from "ember-htmlbars/compat/helper"; -export var ISNT_HELPER_CACHE = new Cache(1000, function(key) { - return key.indexOf('-') === -1; +export var CONTAINS_DASH_CACHE = new Cache(1000, function(key) { + return key.indexOf('-') !== -1; }); +export function validateLazyHelperName(helperName, container, keywords) { + return container && CONTAINS_DASH_CACHE.get(helperName) && !(helperName in keywords); +} + /** Used to lookup/resolve handlebars helpers. The lookup order is: @@ -28,40 +30,19 @@ export var ISNT_HELPER_CACHE = new Cache(1000, function(key) { */ export function findHelper(name, view, env) { var helper = env.helpers[name]; - if (helper) { - return helper; - } - - var container = env.container; - - if (!container || ISNT_HELPER_CACHE.get(name)) { - return; - } - if (name in env.hooks.keywords) { - return; - } - - var helperName = 'helper:' + name; - helper = container.lookup(helperName); if (!helper) { - var componentLookup = container.lookup('component-lookup:main'); - Ember.assert("Could not find 'component-lookup:main' on the provided container," + - " which is necessary for performing component lookups", componentLookup); - - var Component = componentLookup.lookupFactory(name, container); - if (Component) { - helper = makeViewHelper(Component); - container._registry.register(helperName, helper); + var container = env.container; + if (validateLazyHelperName(name, container, env.hooks.keywords)) { + var helperName = 'helper:' + name; + if (container._registry.has(helperName)) { + var _helper; + Ember.assert(`The factory for "${name}" is not an Ember helper. Please use Ember.Helper.build to wrap helper functions.`, (_helper = container._registry.resolve(helperName)) && _helper && (_helper.isHelperFactory || _helper.isHelperInstance || _helper.isHTMLBars)); + helper = container.lookupFactory(helperName); + } } } - if (helper && !helper.isHTMLBars) { - helper = new HandlebarsCompatibleHelper(helper); - container._registry.unregister(helperName); - container._registry.register(helperName, helper); - } - return helper; }
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
packages/ember-htmlbars/lib/system/make_bound_helper.js
@@ -3,8 +3,7 @@ @submodule ember-htmlbars */ -import Helper from "ember-htmlbars/system/helper"; -import { readHash, readArray } from "ember-metal/streams/utils"; +import Helper from "ember-htmlbars/helper"; /** Create a bound helper. Accepts a function that receives the ordered and hash parameters @@ -50,8 +49,5 @@ import { readHash, readArray } from "ember-metal/streams/utils"; @since 1.10.0 */ export default function makeBoundHelper(fn) { - return new Helper(function(params, hash, templates) { - Ember.assert("makeBoundHelper generated helpers do not support use with blocks", !templates.template.meta); - return fn(readArray(params), readHash(hash)); - }); + return Helper.helper(fn); }
true
Other
emberjs
ember.js
334b3df0aff2038ceda0293fecebc1ee16cc8d54.json
Implement Ember.Helper API
packages/ember-htmlbars/lib/utils/is-component.js
@@ -3,7 +3,7 @@ @submodule ember-htmlbars */ -import { ISNT_HELPER_CACHE } from "ember-htmlbars/system/lookup-helper"; +import { CONTAINS_DASH_CACHE } from "ember-htmlbars/system/lookup-helper"; /* Given a path name, returns whether or not a component with that @@ -12,7 +12,7 @@ import { ISNT_HELPER_CACHE } from "ember-htmlbars/system/lookup-helper"; export default function isComponent(env, scope, path) { var container = env.container; if (!container) { return false; } - if (ISNT_HELPER_CACHE.get(path)) { return false; } + if (!CONTAINS_DASH_CACHE.get(path)) { return false; } return container._registry.has('component:' + path) || container._registry.has('template:components/' + path); }
true