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

[CLEANUP beta] Remove {{with}} keyword's controller option. #12001

Merged
merged 1 commit into from
Aug 6, 2015
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
38 changes: 0 additions & 38 deletions packages/ember-htmlbars/lib/keywords/with.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,7 @@
import Ember from 'ember-metal/core';
import { get } from 'ember-metal/property_get';
import { internal } from 'htmlbars-runtime';
import { read } from 'ember-metal/streams/utils';

export default {
setupState(state, env, scope, params, hash) {
var controller = hash.controller;

if (controller) {
if (!state.controller) {
var context = params[0];
var controllerFactory = env.container.lookupFactory('controller:' + controller);
var parentController = null;

if (scope.locals.controller) {
parentController = read(scope.locals.controller);
} else if (scope.locals.view) {
parentController = get(read(scope.locals.view), 'context');
}

var controllerInstance = controllerFactory.create({
model: env.hooks.getValue(context),
parentController: parentController,
target: parentController
});

params[0] = controllerInstance;
return { controller: controllerInstance };
}

return state;
}

return { controller: null };
},

isStable() {
return true;
},
Expand All @@ -44,11 +11,6 @@ export default {
},

render(morph, env, scope, params, hash, template, inverse, visitor) {
if (morph.state.controller) {
morph.addDestruction(morph.state.controller);
hash.controller = morph.state.controller;
}

Ember.assert(
'{{#with foo}} must be called with a single argument or the use the ' +
'{{#with foo as |bar|}} syntax',
Expand Down
43 changes: 0 additions & 43 deletions packages/ember-htmlbars/tests/helpers/with_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import EmberView from 'ember-views/views/view';
import run from 'ember-metal/run_loop';
import EmberObject from 'ember-runtime/system/object';
import { set } from 'ember-metal/property_set';
import EmberController from 'ember-runtime/controllers/controller';
import { Registry } from 'ember-runtime/system/container';
import compile from 'ember-template-compiler/system/compile';
import { runAppend, runDestroy } from 'ember-runtime/tests/utils';

Expand Down Expand Up @@ -187,47 +185,6 @@ QUnit.test('it should support #with this as |qux|', function() {
runDestroy(view);
});

QUnit.module('Handlebars {{#with foo as |bar|}} with defined controller');

QUnit.test('destroys the controller generated with {{with foo as |bar| controller=\'blah\'}}', function() {
var destroyed = false;
var Controller = EmberController.extend({
willDestroy() {
this._super.apply(this, arguments);
destroyed = true;
}
});

var person = EmberObject.create({ name: 'Steve Holt' });
var registry = new Registry();
var container = registry.container();

var parentController = EmberObject.create({
container: container,
person: person,
name: 'Bob Loblaw'
});

var template;
expectDeprecation(function() {
template = compile('{{#with person controller="person" as |steve|}}{{controllerName}}{{/with}}');
}, `Using the {{with}} helper with a \`controller\` specified (L1:C0) is deprecated and will be removed in 2.0.0.`);

view = EmberView.create({
controller: parentController,
template,
container
});

registry.register('controller:person', Controller);

runAppend(view);

runDestroy(view);

ok(destroyed, 'controller was destroyed properly');
});

QUnit.module('{{#with}} helper binding to view keyword', {
setup() {
Ember.lookup = lookup = { Ember: Ember };
Expand Down
2 changes: 0 additions & 2 deletions packages/ember-template-compiler/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import TransformTopLevelComponents from 'ember-template-compiler/plugins/transfo
import TransformEachIntoCollection from 'ember-template-compiler/plugins/transform-each-into-collection';
import DeprecateViewAndControllerPaths from 'ember-template-compiler/plugins/deprecate-view-and-controller-paths';
import DeprecateViewHelper from 'ember-template-compiler/plugins/deprecate-view-helper';
import DeprecateWithController from 'ember-template-compiler/plugins/deprecate-with-controller';

// used for adding Ember.Handlebars.compile for backwards compat
import 'ember-template-compiler/compat';
Expand All @@ -28,7 +27,6 @@ registerPlugin('ast', TransformComponentCurlyToReadonly);
registerPlugin('ast', TransformAngleBracketComponents);
registerPlugin('ast', TransformInputOnToOnEvent);
registerPlugin('ast', TransformTopLevelComponents);
registerPlugin('ast', DeprecateWithController);

if (_Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT) {
registerPlugin('ast', TransformEachIntoCollection);
Expand Down

This file was deleted.

This file was deleted.