Skip to content

Commit

Permalink
Remove ControllerContentModelAliasDeprecation for deprecatingAlias
Browse files Browse the repository at this point in the history
So, this is kind of a fun one.

From what I can tell, `ControllerContentModelAliasDeprecation` was
introduced, due to Controllers having a `content` property, which
`model` was aliased to.
This was done because `ObjectController` and `ArrayController`
were proxying controllers.

But, in Ember, routes set up the `model` property of its respective
controller.
What this meant is that if someone declared a `content` property
in their controller, `model` would—seemingly unrelated—break,
hence the `ControllerContentModelAliasDeprecation` mixin.

Nowadays it is fine to override `content` because the source of
truth was reverse, and `model` is now the primary property, being
`content` the alias.
It is, then, time to remove the old deprecation and instead
deprecate the alias itself, so that in the future users can define
a `content` property in their controllers if they so desire.

Another API bites the dust.
Here's to removing yet more code in the future, and make Ember
sparkle-clean.
  • Loading branch information
locks committed Jul 31, 2017
1 parent 6569e68 commit 5705ec5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 56 deletions.
2 changes: 1 addition & 1 deletion features.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
"ember-views.render-double-modify": "2.0.0",
"ember-routing.router-resource": "2.0.0",
"ember-routing.top-level-render-helper": "2.11.0",
"ember-runtime.controller-content": "2.16.0",
"ember-runtime.controller-proxy": "2.0.0",
"ember-runtime.action-handler-_actions": "2.0.0",
"ember-runtime.enumerable-contains": "2.7.0",
"ember-runtime.will-merge-mixin": "2.0.0",
"ember-runtime.frozen-copy": "2.0.0",
"ember-runtime.freezable-init": "2.0.0",
"ember-string-utils.fmt": "2.0.0",
Expand Down
13 changes: 8 additions & 5 deletions packages/ember-runtime/lib/mixins/controller.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Mixin, alias } from 'ember-metal';
import { deprecatingAlias } from '../computed/computed_macros';
import ActionHandler from './action_handler';
import ControllerContentModelAliasDeprecation from './controller_content_model_alias_deprecation';

/**
@class ControllerMixin
@namespace Ember
@uses Ember.ActionHandler
@private
*/
export default Mixin.create(ActionHandler, ControllerContentModelAliasDeprecation, {
export default Mixin.create(ActionHandler, {
/* ducktype as a controller */
isController: true,

Expand Down Expand Up @@ -38,12 +38,15 @@ export default Mixin.create(ActionHandler, ControllerContentModelAliasDeprecatio
@property model
@public
*/
*/
model: null,

/**
@private
*/
content: alias('model')

content: deprecatingAlias('model', {
id: 'ember-runtime.controller.content-alias',
until: '2.17.0',
url: 'https://emberjs.com/deprecations/v2.x/#toc_controller-content-alias'
})
});

This file was deleted.

4 changes: 3 additions & 1 deletion packages/ember-runtime/tests/controllers/controller_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ QUnit.test('`model` is aliased as `content`', function() {
model: 'foo-bar'
}).create();

equal(controller.get('content'), 'foo-bar', 'content is an alias of model');
expectDeprecation(function () {
equal(controller.get('content'), 'foo-bar', 'content is an alias of model');
});
});

QUnit.test('`content` is moved to `model` when `model` is unset', function() {
Expand Down

0 comments on commit 5705ec5

Please sign in to comment.