Skip to content

Commit

Permalink
Merge pull request #11845 from rwjblue/remove-application-initialize
Browse files Browse the repository at this point in the history
[CLEANUP beta] Remove many deprecations identified in deprecation sweep.
  • Loading branch information
rwjblue committed Jul 21, 2015
2 parents b5025c7 + 9110bab commit b07a809
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 419 deletions.
33 changes: 1 addition & 32 deletions packages/ember-application/lib/system/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,24 +541,6 @@ var Application = Namespace.extend({
this.registry.injection(...arguments);
},

/**
Calling initialize manually is not supported.
Please see Ember.Application#advanceReadiness and
Ember.Application#deferReadiness.
@private
@deprecated
@method initialize
**/
initialize() {
Ember.deprecate(
'Calling initialize manually is not supported. Please see Ember.Application#advanceReadiness and Ember.Application#deferReadiness',
false,
{ id: 'ember-application.initialize', until: '3.0.0' }
);
},

/**
Initialize the application. This happens automatically.
Expand Down Expand Up @@ -1085,13 +1067,7 @@ Application.reopenClass({
@return {*} the resolved value for a given lookup
*/
function resolverFor(namespace) {
Ember.deprecate(
'Application.resolver is deprecated in favor of Application.Resolver',
!namespace.get('resolver'),
{ id: 'ember-application.resolverFor', until: '3.0.0' }
);

var ResolverClass = namespace.get('resolver') || namespace.get('Resolver') || DefaultResolver;
var ResolverClass = namespace.get('Resolver') || DefaultResolver;
var resolver = ResolverClass.create({
namespace: namespace
});
Expand All @@ -1111,13 +1087,6 @@ function resolverFor(namespace) {
resolve.normalize = function(fullName) {
if (resolver.normalize) {
return resolver.normalize(fullName);
} else {
Ember.deprecate(
'The Resolver should now provide a \'normalize\' function',
false,
{ id: 'ember-application.resolve-normalize', until: '3.0.0' }
);
return fullName;
}
};

Expand Down
16 changes: 1 addition & 15 deletions packages/ember-htmlbars/lib/compat/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ function HandlebarsCompatibleHelper(fn) {

fnResult = fn.apply(this, args);

if (options.element) {
Ember.deprecate('Returning a string of attributes from a helper inside an element is deprecated.', false, { id: 'ember-htmlbars.handlebars-compat-helper', until: '3.0.0' });
applyAttributes(env.dom, options.element, fnResult);
} else if (!options.template.yield) {
if (!options.template.yield) {
return fnResult;
}
};
Expand Down Expand Up @@ -148,15 +145,4 @@ export function handlebarsHelper(name, value) {
}
}

function applyAttributes(dom, element, innerString) {
var string = `<${element.tagName} ${innerString}></div>`;
var fragment = dom.parseHTML(string, dom.createElement(element.tagName));

var attrs = fragment.firstChild.attributes;

for (let i = 0, l = attrs.length; i < l; i++) {
element.setAttributeNode(attrs[i].cloneNode());
}
}

export default HandlebarsCompatibleHelper;
4 changes: 0 additions & 4 deletions packages/ember-htmlbars/lib/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ merge(emberHooks, {
import debuggerKeyword from 'ember-htmlbars/keywords/debugger';
import withKeyword from 'ember-htmlbars/keywords/with';
import outlet from 'ember-htmlbars/keywords/outlet';
import realOutlet from 'ember-htmlbars/keywords/real_outlet';
import customizedOutlet from 'ember-htmlbars/keywords/customized_outlet';
import unbound from 'ember-htmlbars/keywords/unbound';
import view from 'ember-htmlbars/keywords/view';
import componentKeyword from 'ember-htmlbars/keywords/component';
Expand All @@ -89,8 +87,6 @@ import getKeyword from 'ember-htmlbars/keywords/get';
registerKeyword('debugger', debuggerKeyword);
registerKeyword('with', withKeyword);
registerKeyword('outlet', outlet);
registerKeyword('@real_outlet', realOutlet);
registerKeyword('@customized_outlet', customizedOutlet);
registerKeyword('unbound', unbound);
registerKeyword('component', componentKeyword);
registerKeyword('partial', partial);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function legacyEachWithControllerHelper(params, hash, blocks) {
var self;

if (blocks.template.arity === 0) {
Ember.deprecate(deprecation, false, { id: 'ember-htmlbars.each-with-controller-helper', until: '3.0.0' });
Ember.deprecate(deprecation, false, { id: 'ember-htmlbars.each-with-controller-helper', until: '2.4.0' });
self = normalizeSelf(item);
self = bindController(self, true);
}
Expand All @@ -36,4 +36,3 @@ function bindController(controller, isSelf) {
}

export var deprecation = 'Using the context switching form of {{each}} is deprecated. Please use the keyword form (`{{#each items as |item|}}`) instead.';

25 changes: 1 addition & 24 deletions packages/ember-htmlbars/lib/hooks/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,10 @@
@submodule ember-htmlbars
*/

import Ember from 'ember-metal/core';
import { findHelper } from 'ember-htmlbars/system/lookup-helper';
import { handleRedirect } from 'htmlbars-runtime/hooks';
import { buildHelperStream } from 'ember-htmlbars/system/invoke-helper';

var fakeElement;

function updateElementAttributesFromString(element, string) {
if (!fakeElement) {
fakeElement = document.createElement('div');
}

fakeElement.innerHTML = '<' + element.tagName + ' ' + string + '><' + '/' + element.tagName + '>';

var attrs = fakeElement.firstChild.attributes;
for (var i = 0, l = attrs.length; i < l; i++) {
var attr = attrs[i];
if (attr.specified) {
element.setAttribute(attr.name, attr.value);
}
}
}

export default function emberElement(morph, env, scope, path, params, hash, visitor) {
if (handleRedirect(morph, env, scope, path, params, hash, null, null, visitor)) {
return;
Expand All @@ -40,9 +21,5 @@ export default function emberElement(morph, env, scope, path, params, hash, visi
result = env.hooks.get(env, scope, path);
}

var value = env.hooks.getValue(result);
if (value) {
Ember.deprecate('Returning a string of attributes from a helper inside an element is deprecated.', false, { id: 'ember-htmlbars.ember-element-value', until: '3.0.0' });
updateElementAttributesFromString(morph.element, value);
}
env.hooks.getValue(result);
}
33 changes: 0 additions & 33 deletions packages/ember-htmlbars/lib/keywords/customized_outlet.js

This file was deleted.

113 changes: 100 additions & 13 deletions packages/ember-htmlbars/lib/keywords/outlet.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,108 @@
*/

import Ember from 'ember-metal/core';
import { keyword } from 'htmlbars-runtime/hooks';
import { get } from 'ember-metal/property_get';
import ViewNodeManager from 'ember-htmlbars/node-managers/view-node-manager';
import topLevelViewTemplate from 'ember-htmlbars/templates/top-level-view';
topLevelViewTemplate.meta.revision = 'Ember@VERSION_STRING_PLACEHOLDER';

/*
This level of delegation handles backward-compatibility with the
`view` parameter to {{outlet}}. When we drop support for the `view`
parameter in 2.0, this keyword should just get replaced directly
with @real_outlet.
*/
export default {
willRender(renderNode, env) {
env.view.ownerView._outlets.push(renderNode);
},

setupState(state, env, scope, params, hash) {
var outletState = env.outletState;
var read = env.hooks.getValue;
var outletName = read(params[0]) || 'main';
var selectedOutletState = outletState[outletName];

var toRender = selectedOutletState && selectedOutletState.render;
if (toRender && !toRender.template && !toRender.ViewClass) {
toRender.template = topLevelViewTemplate;
}

return {
outletState: selectedOutletState,
hasParentOutlet: env.hasParentOutlet,
manager: state.manager
};
},

childEnv(state, env) {
return env.childWithOutletState(state.outletState && state.outletState.outlets, true);
},

isStable(lastState, nextState) {
return isStable(lastState.outletState, nextState.outletState);
},

isEmpty(state) {
return isEmpty(state.outletState);
},

render(renderNode, env, scope, params, hash, template, inverse, visitor) {
var state = renderNode.state;
var parentView = env.view;
var outletState = state.outletState;
var toRender = outletState.render;
var namespace = env.container.lookup('application:main');
var LOG_VIEW_LOOKUPS = get(namespace, 'LOG_VIEW_LOOKUPS');

var ViewClass = outletState.render.ViewClass;

if (!state.hasParentOutlet && !ViewClass) {
ViewClass = env.container.lookupFactory('view:toplevel');
}

var options = {
component: ViewClass,
self: toRender.controller,
createOptions: {
controller: toRender.controller
}
};

export default function(morph, env, scope, params, hash, template, inverse, visitor) {
if (hash.hasOwnProperty('view') || hash.hasOwnProperty('viewClass')) {
Ember.deprecate('Passing `view` or `viewClass` to {{outlet}} is deprecated.', false, { id: 'ember-htmlbars.pass-view-to-outlet', until: '3.0.0' });
keyword('@customized_outlet', morph, env, scope, params, hash, template, inverse, visitor);
} else {
keyword('@real_outlet', morph, env, scope, params, hash, template, inverse, visitor);
template = template || toRender.template && toRender.template.raw;

if (LOG_VIEW_LOOKUPS && ViewClass) {
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;

nodeManager.render(env, hash, visitor);
}
};

function isEmpty(outletState) {
return !outletState || (!outletState.render.ViewClass && !outletState.render.template);
}

function isStable(a, b) {
if (!a && !b) {
return true;
}
if (!a || !b) {
return false;
}
a = a.render;
b = b.render;
for (var key in a) {
if (a.hasOwnProperty(key)) {
// name is only here for logging & debugging. If two different
// names result in otherwise identical states, they're still
// identical.
if (a[key] !== b[key] && key !== 'name') {
return false;
}
}
}
return true;
}
Loading

0 comments on commit b07a809

Please sign in to comment.