Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove _ENABLE_LEGACY_CONTROLLER_SUPPORT. #13192

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/ember-application/lib/system/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@submodule ember-application
*/
import Ember from 'ember-metal'; // Ember.libraries, LOG_VERSION, Namespace, BOOTED
import { assert, debug, deprecate } from 'ember-metal/debug';
import { assert, debug, warn, deprecate } from 'ember-metal/debug';
import { get } from 'ember-metal/property_get';
import { runLoadHooks } from 'ember-runtime/system/lazy_load';
import run from 'ember-metal/run_loop';
Expand Down Expand Up @@ -605,10 +605,10 @@ const Application = Engine.extend({
}

if (Ember.ENV._ENABLE_LEGACY_CONTROLLER_SUPPORT && !warnedAboutLegacyControllerAddon) {
deprecate(
'Support for the `ember-legacy-controllers` addon will end soon, please remove it from your application.',
warn(
'Support for the `ember-legacy-controllers` has been removed, please remove it from your application.',
false,
{ id: 'ember-legacy-controllers', until: '2.6.0', url: 'http://emberjs.com/deprecations/v1.x/#toc_objectcontroller' }
{ id: 'ember-legacy-controllers', url: 'http://emberjs.com/deprecations/v1.x/#toc_objectcontroller' }
);

warnedAboutLegacyControllerAddon = true;
Expand Down
34 changes: 27 additions & 7 deletions packages/ember-application/tests/system/application_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ import { getDebugFunction, setDebugFunction } from 'ember-metal/debug';

var trim = jQuery.trim;

var app, application, originalLookup, originalDebug;
var app, application, originalLookup, originalDebug, originalWarn;

QUnit.module('Ember.Application', {
setup() {
originalLookup = Ember.lookup;
originalDebug = getDebugFunction('debug');
originalWarn = getDebugFunction('warn');

jQuery('#qunit-fixture').html('<div id=\'one\'><div id=\'one-child\'>HI</div></div><div id=\'two\'>HI</div>');
run(function() {
Expand All @@ -34,6 +35,7 @@ QUnit.module('Ember.Application', {
teardown() {
jQuery('#qunit-fixture').empty();
setDebugFunction('debug', originalDebug);
setDebugFunction('warn', originalWarn);

Ember.lookup = originalLookup;

Expand Down Expand Up @@ -363,12 +365,18 @@ QUnit.module('Ember.Application - legacy addon deprecation warnings', {
_ENABLE_LEGACY_CONTROLLER_SUPPORT: false
});

originalDebug = getDebugFunction('debug');
originalWarn = getDebugFunction('warn');

_resetLegacyAddonWarnings();
},

teardown() {
Ember.ENV = originalEmberENV;

setDebugFunction('debug', originalDebug);
setDebugFunction('warn', originalWarn);

if (app) {
run(app, 'destroy');
}
Expand Down Expand Up @@ -407,16 +415,28 @@ QUnit.test('it does not warn about the ember-legacy-controllers addon on first b
});

QUnit.test('it warns about the ember-legacy-controllers addon on first boot when installed', function() {
if (EmberDev.runningProdBuild) {
ok(true, 'warnings are disabled in prod builds');
return;
}

Ember.ENV._ENABLE_LEGACY_CONTROLLER_SUPPORT = true;

expectDeprecation(() => {
app = run(Application, 'create');
}, 'Support for the `ember-legacy-controllers` addon will end soon, please remove it from your application.');
let warning;
setDebugFunction('warn', function(message, test) {
if (!test) {
warning = message;
}
});

app = run(Application, 'create');

equal(warning, 'Support for the `ember-legacy-controllers` has been removed, please remove it from your application.');

run(app, 'destroy');
warning = null;

// It should not warn again on second boot
expectNoDeprecation(() => {
app = run(Application, 'create');
});
app = run(Application, 'create');
equal(warning, null);
});
23 changes: 1 addition & 22 deletions packages/ember-htmlbars/lib/hooks/bind-self.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,12 @@
import _Ember from 'ember-metal';
import ProxyStream from 'ember-metal/streams/proxy-stream';

export default function bindSelf(env, scope, _self) {
let self = _self;

if (self && self.hasBoundController) {
let { controller } = self;
self = self.self;

if (!!_Ember.ENV._ENABLE_LEGACY_CONTROLLER_SUPPORT) {
scope.bindLocal('controller', newStream(controller || self));
}
}

export default function bindSelf(env, scope, self) {
if (self && self.isView) {
if (!!_Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT) {
scope.bindLocal('view', newStream(self, 'view'));
}

if (!!_Ember.ENV._ENABLE_LEGACY_CONTROLLER_SUPPORT) {
scope.bindLocal('controller', newStream(self, '').getKey('controller'));
}

let selfStream = newStream(self, '');

if (self.isGlimmerComponent) {
Expand All @@ -40,12 +25,6 @@ export default function bindSelf(env, scope, _self) {

let selfStream = newStream(self, '');
scope.bindSelf(selfStream);

if (!!_Ember.ENV._ENABLE_LEGACY_CONTROLLER_SUPPORT) {
if (!scope.hasLocal('controller')) {
scope.bindLocal('controller', selfStream);
}
}
}

function newStream(newValue, key) {
Expand Down
11 changes: 0 additions & 11 deletions packages/ember-htmlbars/lib/hooks/bind-shadow-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,10 @@ import ProxyStream from 'ember-metal/streams/proxy-stream';
export default function bindShadowScope(env, parentScope, shadowScope, options) {
if (!options) { return; }

let didOverrideController = false;

if (parentScope && parentScope.overrideController) {
didOverrideController = true;
shadowScope.bindLocal('controller', parentScope.getLocal('controller'));
}

var view = options.view;
if (view && !view.isComponent) {
shadowScope.bindLocal('view', newStream(view, 'view'));

if (!didOverrideController) {
shadowScope.bindLocal('controller', newStream(shadowScope.getLocal('view').getKey('controller')));
}

if (view.isView) {
shadowScope.bindSelf(newStream(shadowScope.getLocal('view').getKey('context'), ''));
}
Expand Down
7 changes: 0 additions & 7 deletions packages/ember-htmlbars/lib/hooks/create-fresh-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ import EmptyObject from 'ember-metal/empty_object';
use the component itself as the `this`.
* If `self` is a view, two special locals are created: `view` and
`controller`. These locals are legacy semantics.
* If self has a `hasBoundController` property, it is coming from
a legacy form of #with
(`{{#with something controller=someController}}`). This has
the special effect of giving the child scope the supplied
`controller` keyword, with an unrelated `self`. This is
legacy functionality, as both the `view` and `controller`
keywords have been deprecated.

**IMPORTANT**: There are two places in Ember where the ambient
controller is looked up. Both of those places use the presence
Expand Down
100 changes: 0 additions & 100 deletions packages/ember-htmlbars/tests/compat/controller_keyword_test.js

This file was deleted.

77 changes: 2 additions & 75 deletions packages/ember-htmlbars/tests/helpers/view_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,19 +366,6 @@ QUnit.test('Should apply class without condition always', function() {
ok(jQuery('#foo').hasClass('foo'), 'Always applies classbinding without condition');
});

QUnit.test('Should apply classes when bound controller.* property specified', function() {
view = EmberView.create({
controller: {
someProp: 'foo'
},
template: compile('{{#view id="foo" class=controller.someProp}} Foo{{/view}}')
});

runAppend(view);

ok(jQuery('#foo').hasClass('foo'), 'Always applies classbinding without condition');
});

QUnit.test('Should apply classes when bound property specified', function() {
view = EmberView.create({
controller: {
Expand Down Expand Up @@ -936,66 +923,6 @@ QUnit.test('a view helper\'s bindings are to the parent context', function() {
equal(view.$('h1 .mauve').text(), 'foo bar', 'renders property bound in template from subview context');
});

QUnit.test('should expose a controller keyword when present on the view', function() {
var templateString = '{{controller.foo}}{{#view}}{{controller.baz}}{{/view}}';
view = EmberView.create({
[OWNER]: owner,
controller: EmberObject.create({
foo: 'bar',
baz: 'bang'
}),

template: compile(templateString)
});

runAppend(view);

equal(view.$().text(), 'barbang', 'renders values from controller and parent controller');

var controller = get(view, 'controller');

run(function() {
controller.set('foo', 'BAR');
controller.set('baz', 'BLARGH');
});

equal(view.$().text(), 'BARBLARGH', 'updates the DOM when a bound value is updated');

runDestroy(view);

view = EmberView.create({
controller: 'aString',
template: compile('{{controller}}')
});

runAppend(view);

equal(view.$().text(), 'aString', 'renders the controller itself if no additional path is specified');
});

QUnit.test('should expose a controller keyword that can be used in conditionals', function() {
var templateString = '{{#view}}{{#if controller}}{{controller.foo}}{{/if}}{{/view}}';
view = EmberView.create({
[OWNER]: owner,

controller: EmberObject.create({
foo: 'bar'
}),

template: compile(templateString)
});

runAppend(view);

equal(view.$().text(), 'bar', 'renders values from controller and parent controller');

run(function() {
view.set('controller', null);
});

equal(view.$().text(), '', 'updates the DOM when the controller is changed');
});

QUnit.test('should expose a controller that can be used in the view instance', function() {
var templateString = '{{#view view.childThing tagName="div"}}Stuff{{/view}}';
var controller = {
Expand Down Expand Up @@ -1077,7 +1004,7 @@ QUnit.test('bindings should respect keywords [DEPRECATED]', function() {
template: compile('Name: {{view.attrs.name}} Price: ${{view.attrs.dollars}}')
}),

template: compile('{{#if view.museumOpen}}{{view view.museumView name=controller.museumDetails.name dollars=controller.museumDetails.price}}{{/if}}')
template: compile('{{#if view.museumOpen}}{{view view.museumView name=museumDetails.name dollars=museumDetails.price}}{{/if}}')
});

runAppend(view);
Expand All @@ -1101,7 +1028,7 @@ QUnit.test('should respect keywords', function() {
template: compile('Name: {{view.attrs.name}} Price: ${{view.attrs.dollars}}')
}),

template: compile('{{#if view.museumOpen}}{{view view.museumView name=controller.museumDetails.name dollars=controller.museumDetails.price}}{{/if}}')
template: compile('{{#if view.museumOpen}}{{view view.museumView name=museumDetails.name dollars=museumDetails.price}}{{/if}}')
});

runAppend(view);
Expand Down
Loading