Skip to content

Commit

Permalink
Merge pull request #13599 from rwjblue/remove-enabled-features
Browse files Browse the repository at this point in the history
Update feature flags.
  • Loading branch information
mixonic committed Jun 4, 2016
2 parents 235a6cb + dbc8641 commit a841b2e
Show file tree
Hide file tree
Showing 15 changed files with 215 additions and 314 deletions.
16 changes: 0 additions & 16 deletions FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,6 @@ for a detailed explanation.
Implements RFC https://github.com/emberjs/rfcs/pull/38, adding support for
routable components.

* `ember-metal-ember-assign`

Add `Ember.assign` that is polyfill for `Object.assign`.

* `ember-htmlbars-local-lookup`

Provides the ability for component lookup to be relative to the source template.

When the proper API's are implemented by the resolver in use this feature allows `{{x-foo}}` in a
given routes template (say the `post` route) to lookup a component nested under `post`.

* `ember-test-helpers-fire-native-events`

Makes ember test helpers (`fillIn`, `click`, `triggerEvent` ...) fire native javascript events instead
of `jQuery.Event`s, maching more closely app's real usage.

* `ember-route-serializers`

Deprecates `Route#serialize` and introduces a `serialize` option to the router DSL as a replacement (as per the [Route Serializers RFC](https://github.com/emberjs/rfcs/blob/master/text/0120-route-serializers.md)).
Expand Down
5 changes: 1 addition & 4 deletions features.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"features": {
"features-stripped-test": null,
"ember-test-helpers-fire-native-events": true,
"ember-routing-route-configured-query-params": null,
"ember-libraries-isregistered": null,
"ember-metal-ember-assign": true,
"ember-htmlbars-local-lookup": true,
"ember-application-engines": null,
"ember-route-serializers": null,
"ember-glimmer": null,
"ember-runtime-computed-uniq-by": null,
"ember-runtime-computed-uniq-by": true,
"ember-improved-instrumentation": null,
"ember-runtime-enumerable-includes": null
}
Expand Down
21 changes: 8 additions & 13 deletions packages/container/lib/container.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ENV } from 'ember-environment';
import { assert, deprecate, runInDebug } from 'ember-metal/debug';
import dictionary from 'ember-metal/dictionary';
import isEnabled from 'ember-metal/features';
import { setOwner, OWNER } from './owner';
import { buildFakeContainerWithDeprecations } from 'ember-runtime/mixins/container_proxy';
import symbol from 'ember-metal/symbol';
Expand Down Expand Up @@ -183,13 +182,11 @@ function isSingleton(container, fullName) {
}

function lookup(container, fullName, options = {}) {
if (isEnabled('ember-htmlbars-local-lookup')) {
if (options.source) {
fullName = container.registry.expandLocalLookup(fullName, options);
if (options.source) {
fullName = container.registry.expandLocalLookup(fullName, options);

// if expandLocalLookup returns falsey, we do not support local lookup
if (!fullName) { return; }
}
// if expandLocalLookup returns falsey, we do not support local lookup
if (!fullName) { return; }
}

if (container.cache[fullName] !== undefined && options.singleton !== false) {
Expand Down Expand Up @@ -246,13 +243,11 @@ function buildInjections(/* container, ...injections */) {
function factoryFor(container, fullName, options = {}) {
let registry = container.registry;

if (isEnabled('ember-htmlbars-local-lookup')) {
if (options.source) {
fullName = registry.expandLocalLookup(fullName, options);
if (options.source) {
fullName = registry.expandLocalLookup(fullName, options);

// if expandLocalLookup returns falsey, we do not support local lookup
if (!fullName) { return; }
}
// if expandLocalLookup returns falsey, we do not support local lookup
if (!fullName) { return; }
}

var cache = container.factoryCache;
Expand Down
88 changes: 40 additions & 48 deletions packages/container/lib/registry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import isEnabled from 'ember-metal/features';
import { assert, deprecate } from 'ember-metal/debug';
import dictionary from 'ember-metal/dictionary';
import EmptyObject from 'ember-metal/empty_object';
Expand Down Expand Up @@ -349,10 +348,7 @@ Registry.prototype = {
return false;
}

let source;
if (isEnabled('ember-htmlbars-local-lookup')) {
source = options && options.source && this.normalize(options.source);
}
let source = options && options.source && this.normalize(options.source);

return has(this, this.normalize(fullName), source);
},
Expand Down Expand Up @@ -779,42 +775,40 @@ function deprecateResolverFunction(registry) {
};
}

if (isEnabled('ember-htmlbars-local-lookup')) {
/**
Given a fullName and a source fullName returns the fully resolved
fullName. Used to allow for local lookup.
```javascript
var registry = new Registry();
// the twitter factory is added to the module system
registry.expandLocalLookup('component:post-title', { source: 'template:post' }) // => component:post/post-title
```
@private
@method expandLocalLookup
@param {String} fullName
@param {Object} [options]
@param {String} [options.source] the fullname of the request source (used for local lookups)
@return {String} fullName
*/
Registry.prototype.expandLocalLookup = function Registry_expandLocalLookup(fullName, options) {
if (this.resolver && this.resolver.expandLocalLookup) {
assert('fullName must be a proper full name', this.validateFullName(fullName));
assert('options.source must be provided to expandLocalLookup', options && options.source);
assert('options.source must be a proper full name', this.validateFullName(options.source));
/**
Given a fullName and a source fullName returns the fully resolved
fullName. Used to allow for local lookup.
let normalizedFullName = this.normalize(fullName);
let normalizedSource = this.normalize(options.source);
```javascript
var registry = new Registry();
return expandLocalLookup(this, normalizedFullName, normalizedSource);
} else if (this.fallback) {
return this.fallback.expandLocalLookup(fullName, options);
} else {
return null;
}
};
}
// the twitter factory is added to the module system
registry.expandLocalLookup('component:post-title', { source: 'template:post' }) // => component:post/post-title
```
@private
@method expandLocalLookup
@param {String} fullName
@param {Object} [options]
@param {String} [options.source] the fullname of the request source (used for local lookups)
@return {String} fullName
*/
Registry.prototype.expandLocalLookup = function Registry_expandLocalLookup(fullName, options) {
if (this.resolver && this.resolver.expandLocalLookup) {
assert('fullName must be a proper full name', this.validateFullName(fullName));
assert('options.source must be provided to expandLocalLookup', options && options.source);
assert('options.source must be a proper full name', this.validateFullName(options.source));

let normalizedFullName = this.normalize(fullName);
let normalizedSource = this.normalize(options.source);

return expandLocalLookup(this, normalizedFullName, normalizedSource);
} else if (this.fallback) {
return this.fallback.expandLocalLookup(fullName, options);
} else {
return null;
}
};

function expandLocalLookup(registry, normalizedName, normalizedSource) {
let cache = registry._localLookupCache;
Expand All @@ -834,15 +828,13 @@ function expandLocalLookup(registry, normalizedName, normalizedSource) {
}

function resolve(registry, normalizedName, options) {
if (isEnabled('ember-htmlbars-local-lookup')) {
if (options && options.source) {
// when `source` is provided expand normalizedName
// and source into the full normalizedName
normalizedName = registry.expandLocalLookup(normalizedName, options);

// if expandLocalLookup returns falsey, we do not support local lookup
if (!normalizedName) { return; }
}
if (options && options.source) {
// when `source` is provided expand normalizedName
// and source into the full normalizedName
normalizedName = registry.expandLocalLookup(normalizedName, options);

// if expandLocalLookup returns falsey, we do not support local lookup
if (!normalizedName) { return; }
}

var cached = registry._resolveCache[normalizedName];
Expand Down
59 changes: 28 additions & 31 deletions packages/container/tests/container_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { get } from 'ember-metal/property_get';
import Registry from 'container/registry';
import factory from 'container/tests/test-helpers/factory';
import { getOwner, OWNER } from 'container/owner';
import isEnabled from 'ember-metal/features';

var originalModelInjections;

Expand Down Expand Up @@ -674,44 +673,42 @@ QUnit.test('An extendable factory can provide `container` upon create, with a de
}, 'Using the injected `container` is deprecated. Please use the `getOwner` helper instead to access the owner of this object.');
});

if (isEnabled('ember-htmlbars-local-lookup')) {
QUnit.test('lookupFactory passes options through to expandlocallookup', function(assert) {
let registry = new Registry();
let container = registry.container();
let PostController = factory();
QUnit.test('lookupFactory passes options through to expandlocallookup', function(assert) {
let registry = new Registry();
let container = registry.container();
let PostController = factory();

registry.register('controller:post', PostController);
registry.register('controller:post', PostController);

registry.expandLocalLookup = function(fullName, options) {
assert.ok(true, 'expandLocalLookup was called');
assert.equal(fullName, 'foo:bar');
assert.deepEqual(options, { source: 'baz:qux' });
registry.expandLocalLookup = function(fullName, options) {
assert.ok(true, 'expandLocalLookup was called');
assert.equal(fullName, 'foo:bar');
assert.deepEqual(options, { source: 'baz:qux' });

return 'controller:post';
};
return 'controller:post';
};

let PostControllerFactory = container.lookupFactory('foo:bar', { source: 'baz:qux' });
let PostControllerFactory = container.lookupFactory('foo:bar', { source: 'baz:qux' });

assert.ok(PostControllerFactory.create() instanceof PostController, 'The return of factory.create is an instance of PostController');
});
assert.ok(PostControllerFactory.create() instanceof PostController, 'The return of factory.create is an instance of PostController');
});

QUnit.test('lookup passes options through to expandlocallookup', function(assert) {
let registry = new Registry();
let container = registry.container();
let PostController = factory();
QUnit.test('lookup passes options through to expandlocallookup', function(assert) {
let registry = new Registry();
let container = registry.container();
let PostController = factory();

registry.register('controller:post', PostController);
registry.register('controller:post', PostController);

registry.expandLocalLookup = function(fullName, options) {
assert.ok(true, 'expandLocalLookup was called');
assert.equal(fullName, 'foo:bar');
assert.deepEqual(options, { source: 'baz:qux' });
registry.expandLocalLookup = function(fullName, options) {
assert.ok(true, 'expandLocalLookup was called');
assert.equal(fullName, 'foo:bar');
assert.deepEqual(options, { source: 'baz:qux' });

return 'controller:post';
};
return 'controller:post';
};

let PostControllerLookupResult = container.lookup('foo:bar', { source: 'baz:qux' });
let PostControllerLookupResult = container.lookup('foo:bar', { source: 'baz:qux' });

assert.ok(PostControllerLookupResult instanceof PostController);
});
}
assert.ok(PostControllerLookupResult instanceof PostController);
});
5 changes: 0 additions & 5 deletions packages/container/tests/registry_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Registry } from 'container';
import factory from 'container/tests/test-helpers/factory';
import isEnabled from 'ember-metal/features';

QUnit.module('Registry');

Expand Down Expand Up @@ -532,9 +531,6 @@ QUnit.test('A registry can be created with a deprecated `resolver` function inst
equal(registry.resolve('foo:bar'), 'foo:bar-resolved', '`resolve` still calls the deprecated function');
});

if (isEnabled('ember-htmlbars-local-lookup')) {
// jscs:disable validateIndentation

QUnit.test('resolver.expandLocalLookup is not required', function(assert) {
assert.expect(1);

Expand Down Expand Up @@ -752,4 +748,3 @@ QUnit.test('has uses expandLocalLookup', function(assert) {

assert.deepEqual(['foo:qux/bar'], resolvedFullNames);
});
}
13 changes: 5 additions & 8 deletions packages/ember-glimmer/lib/utils/lookup-component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import isEnabled from 'ember-metal/features';
import { privatize as P } from 'container/registry';

const DEFAULT_LAYOUT = P`template:components/-default`;
Expand Down Expand Up @@ -27,15 +26,13 @@ function lookupComponentPair(componentLookup, owner, name, options) {
export default function lookupComponent(owner, name, options) {
let componentLookup = owner.lookup('component-lookup:main');

if (isEnabled('ember-htmlbars-local-lookup')) {
let source = options && options.source;
let source = options && options.source;

if (source) {
let localResult = lookupComponentPair(componentLookup, owner, name, options);
if (source) {
let localResult = lookupComponentPair(componentLookup, owner, name, options);

if (localResult.component || localResult.layout) {
return localResult;
}
if (localResult.component || localResult.layout) {
return localResult;
}
}

Expand Down
9 changes: 3 additions & 6 deletions packages/ember-htmlbars/lib/hooks/component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import isEnabled from 'ember-metal/features';
import { assert } from 'ember-metal/debug';
import ComponentNodeManager from 'ember-htmlbars/node-managers/component-node-manager';
import lookupComponent from 'ember-htmlbars/utils/lookup-component';
Expand Down Expand Up @@ -65,11 +64,9 @@ export default function componentHook(renderNode, env, scope, _tagName, params,

let parentView = env.view;
let options = { };
if (isEnabled('ember-htmlbars-local-lookup')) {
let moduleName = env.meta && env.meta.moduleName;
if (moduleName) {
options.source = `template:${moduleName}`;
}
let moduleName = env.meta && env.meta.moduleName;
if (moduleName) {
options.source = `template:${moduleName}`;
}
let { component, layout } = lookupComponent(env.owner, tagName, options);

Expand Down
19 changes: 7 additions & 12 deletions packages/ember-htmlbars/lib/utils/is-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
@submodule ember-htmlbars
*/

import isEnabled from 'ember-metal/features';
import {
CONTAINS_DASH_CACHE,
CONTAINS_DOT_CACHE
Expand Down Expand Up @@ -38,20 +37,16 @@ export default function isComponent(env, scope, path) {
if (hasComponentOrTemplate(owner, path)) {
return true; // global component found
} else {
if (isEnabled('ember-htmlbars-local-lookup')) {
let moduleName = env.meta && env.meta.moduleName;
let moduleName = env.meta && env.meta.moduleName;

if (!moduleName) {
// Without a source moduleName, we can not perform local lookups.
return false;
}

let options = { source: `template:${moduleName}` };

return hasComponentOrTemplate(owner, path, options);
} else {
if (!moduleName) {
// Without a source moduleName, we can not perform local lookups.
return false;
}

let options = { source: `template:${moduleName}` };

return hasComponentOrTemplate(owner, path, options);
}
}
}
Loading

0 comments on commit a841b2e

Please sign in to comment.