Skip to content

Commit

Permalink
MISC Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner committed Oct 9, 2014
1 parent d18dba7 commit 4abbd9b
Show file tree
Hide file tree
Showing 47 changed files with 323 additions and 147 deletions.
10 changes: 8 additions & 2 deletions packages/container/lib/container.js
Expand Up @@ -421,7 +421,10 @@ Container.prototype = {

var fullNameType = fullName.split(':')[0];
if (fullNameType === type) {
throw new Error('Cannot inject a `' + fullName + '` on other ' + type + '(s). Register the `' + fullName + '` as a different type and perform the typeInjection.');
throw new Error('Cannot inject a `' + fullName +
'` on other ' + type +
'(s). Register the `' + fullName +
'` as a different type and perform the typeInjection.');
}

addTypeInjection(this.typeInjections, type, property, fullName);
Expand Down Expand Up @@ -485,7 +488,10 @@ Container.prototype = {
var normalizedName = this.normalize(fullName);

if (this.cache[normalizedName]) {
throw new Error("Attempted to register an injection for a type that has already been looked up. ('" + normalizedName + "', '" + property + "', '" + injectionName + "')");
throw new Error("Attempted to register an injection for a type that has already been looked up. ('" +
normalizedName + "', '" +
property + "', '" +
injectionName + "')");
}

addInjection(initRules(this.injections, normalizedName), property, normalizedInjectionName);
Expand Down
13 changes: 10 additions & 3 deletions packages/ember-application/lib/ext/controller.js
Expand Up @@ -19,7 +19,8 @@ function verifyNeedsDependencies(controller, container, needs) {
for (i=0, l=needs.length; i<l; i++) {
dependency = needs[i];

Ember.assert(inspect(controller) + "#needs must not specify dependencies with periods in their names (" + dependency + ")", dependency.indexOf('.') === -1);
Ember.assert(inspect(controller) + "#needs must not specify dependencies with periods in their names (" +
dependency + ")", dependency.indexOf('.') === -1);

if (dependency.indexOf(':') === -1) {
dependency = "controller:" + dependency;
Expand All @@ -31,7 +32,8 @@ function verifyNeedsDependencies(controller, container, needs) {
}
}
if (missing.length) {
throw new EmberError(inspect(controller) + " needs [ " + missing.join(', ') + " ] but " + (missing.length > 1 ? 'they' : 'it') + " could not be found");
throw new EmberError(inspect(controller) + " needs [ " + missing.join(', ') +
" ] but " + (missing.length > 1 ? 'they' : 'it') + " could not be found");
}
}

Expand All @@ -52,7 +54,12 @@ var defaultControllersComputedProperty = computed(function() {
}
}

var errorMessage = inspect(controller) + '#needs does not include `' + controllerName + '`. To access the ' + controllerName + ' controller from ' + inspect(controller) + ', ' + inspect(controller) + ' should have a `needs` property that is an array of the controllers it has access to.';
var errorMessage = inspect(controller) + '#needs does not include `' +
controllerName + '`. To access the ' +
controllerName + ' controller from ' +
inspect(controller) + ', ' +
inspect(controller) +
' should have a `needs` property that is an array of the controllers it has access to.';
throw new ReferenceError(errorMessage);
},
setUnknownProperty: function (key, value) {
Expand Down
4 changes: 3 additions & 1 deletion packages/ember-application/lib/system/application.js
Expand Up @@ -262,7 +262,9 @@ var Application = Namespace.extend(DeferredMixin, {
_readinessDeferrals: 1,

init: function() {
if (!this.$) { this.$ = jQuery; }
if (!this.$) {
this.$ = jQuery;
}
this.__container__ = this.buildContainer();

this.Router = this.defaultRouter();
Expand Down
8 changes: 6 additions & 2 deletions packages/ember-application/lib/system/resolver.js
Expand Up @@ -121,7 +121,9 @@ export default EmberObject.extend({
var type = split[0];
var name = split[1];

Ember.assert("Tried to normalize a container name without a colon (:) in it. You probably tried to lookup a name that did not contain a type, a colon, and a name. A proper lookup name would be `view:post`.", split.length === 2);
Ember.assert("Tried to normalize a container name without a colon (:) in it." +
" You probably tried to lookup a name that did not contain a type," +
" a colon, and a name. A proper lookup name would be `view:post`.", split.length === 2);

if (type !== 'template') {
var result = name;
Expand Down Expand Up @@ -206,7 +208,9 @@ export default EmberObject.extend({
var namespaceName = capitalize(parts.slice(0, -1).join('.'));
root = Namespace.byName(namespaceName);

Ember.assert('You are looking for a ' + name + ' ' + type + ' in the ' + namespaceName + ' namespace, but the namespace could not be found', root);
Ember.assert('You are looking for a ' + name + ' ' + type +
' in the ' + namespaceName +
' namespace, but the namespace could not be found', root);
}

return {
Expand Down
6 changes: 4 additions & 2 deletions packages/ember-handlebars-compiler/lib/main.js
Expand Up @@ -109,7 +109,8 @@ EmberHandlebars.helper = function(name, value) {
if (!View) { View = requireModule('ember-views/views/view')['default']; } // ES6TODO: stupid circular dep
if (!Component) { Component = requireModule('ember-views/views/component')['default']; } // ES6TODO: stupid circular dep

Ember.assert("You tried to register a component named '" + name + "', but component names must include a '-'", !Component.detect(value) || name.match(/-/));
Ember.assert("You tried to register a component named '" + name +
"', but component names must include a '-'", !Component.detect(value) || name.match(/-/));

if (View.detect(value)) {
EmberHandlebars.registerHelper(name, EmberHandlebars.makeViewHelper(value));
Expand All @@ -132,7 +133,8 @@ EmberHandlebars.helper = function(name, value) {
*/
EmberHandlebars.makeViewHelper = function(ViewClass) {
return function(options) {
Ember.assert("You can only pass attributes (such as name=value) not bare values to a helper for a View found in '" + ViewClass.toString() + "'", arguments.length < 2);
Ember.assert("You can only pass attributes (such as name=value) not bare " +
"values to a helper for a View found in '" + ViewClass.toString() + "'", arguments.length < 2);
return EmberHandlebars.helpers.view.call(this, ViewClass, options);
};
};
Expand Down
4 changes: 1 addition & 3 deletions packages/ember-handlebars/lib/component_lookup.js
@@ -1,6 +1,6 @@
import EmberObject from "ember-runtime/system/object";

var ComponentLookup = EmberObject.extend({
export default EmberObject.extend({
lookupFactory: function(name, container) {

container = container || this.container;
Expand All @@ -26,5 +26,3 @@ var ComponentLookup = EmberObject.extend({
}
}
});

export default ComponentLookup;
3 changes: 2 additions & 1 deletion packages/ember-handlebars/lib/controls.js
Expand Up @@ -207,7 +207,8 @@ export function inputHelper(options) {
delete hash.type;
delete types.type;

Ember.assert("{{input type='checkbox'}} does not support setting `value=someBooleanValue`; you must use `checked=someBooleanValue` instead.", options.hashTypes.value !== 'ID');
Ember.assert("{{input type='checkbox'}} does not support setting `value=someBooleanValue`;" +
" you must use `checked=someBooleanValue` instead.", options.hashTypes.value !== 'ID');

return EmberHandlebars.helpers.view.call(this, Checkbox, options);
} else {
Expand Down
11 changes: 10 additions & 1 deletion packages/ember-handlebars/lib/controls/text_area.js
Expand Up @@ -31,7 +31,16 @@ export default Component.extend(TextSupport, {
classNames: ['ember-text-area'],

tagName: "textarea",
attributeBindings: ['rows', 'cols', 'name', 'selectionEnd', 'selectionStart', 'wrap', 'lang', 'dir'],
attributeBindings: [
'rows',
'cols',
'name',
'selectionEnd',
'selectionStart',
'wrap',
'lang',
'dir'
],
rows: null,
cols: null,

Expand Down
30 changes: 25 additions & 5 deletions packages/ember-handlebars/lib/controls/text_field.js
Expand Up @@ -28,11 +28,31 @@ export default Component.extend(TextSupport, {

classNames: ['ember-text-field'],
tagName: "input",
attributeBindings: ['type', 'value', 'size', 'pattern', 'name', 'min', 'max',
'accept', 'autocomplete', 'autosave', 'formaction',
'formenctype', 'formmethod', 'formnovalidate', 'formtarget',
'height', 'inputmode', 'list', 'multiple', 'step', 'lang', 'dir',
'width'],
attributeBindings: [
'accept',
'autocomplete',
'autosave',
'dir',
'formaction',
'formenctype',
'formmethod',
'formnovalidate',
'formtarget',
'height',
'inputmode',
'lang',
'list',
'max',
'min',
'multiple',
'name',
'pattern',
'size',
'step',
'type',
'value',
'width'
],

/**
The `value` attribute of the input element. As the user inputs text, this
Expand Down
18 changes: 15 additions & 3 deletions packages/ember-handlebars/lib/controls/text_support.js
Expand Up @@ -20,9 +20,21 @@ import TargetActionSupport from "ember-runtime/mixins/target_action_support";
var TextSupport = Mixin.create(TargetActionSupport, {
value: "",

attributeBindings: ['placeholder', 'disabled', 'maxlength', 'tabindex', 'readonly',
'autofocus', 'form', 'selectionDirection', 'spellcheck', 'required',
'title', 'autocapitalize', 'autocorrect'],
attributeBindings: [
'autocapitalize',
'autocorrect',
'autofocus',
'disabled',
'form',
'maxlength',
'placeholder',
'readonly',
'required',
'selectionDirection',
'spellcheck',
'tabindex',
'title'
],
placeholder: null,
disabled: false,
maxlength: null,
Expand Down
16 changes: 12 additions & 4 deletions packages/ember-handlebars/lib/ext.js
Expand Up @@ -166,7 +166,9 @@ function handlebarsGetView(context, path, container, data) {
}
if (!viewClass && isGlobal) {
var globalViewClass = get(path);
Ember.deprecate('Resolved the view "'+path+'" on the global context. Pass a view name to be looked up on the container instead, such as {{view "select"}}. http://emberjs.com/guides/deprecations#toc_global-lookup-of-views-since-1-8', !globalViewClass);
Ember.deprecate('Resolved the view "'+path+'" on the global context. Pass a view name to be looked' +
' up on the container instead, such as {{view "select"}}.' +
' http://emberjs.com/guides/deprecations#toc_global-lookup-of-views-since-1-8', !globalViewClass);
if (globalViewClass) {
viewClass = globalViewClass;
}
Expand Down Expand Up @@ -266,7 +268,9 @@ export function resolveHash(context, hash, options) {
@param {Hash} options
*/
export function helperMissingHelper(path) {
if (!resolveHelper) { resolveHelper = requireModule('ember-handlebars/helpers/binding')['resolveHelper']; } // ES6TODO: stupid circular dep
if (!resolveHelper) {
resolveHelper = requireModule('ember-handlebars/helpers/binding')['resolveHelper'];
} // ES6TODO: stupid circular dep

var error, view = "";

Expand Down Expand Up @@ -300,7 +304,9 @@ export function helperMissingHelper(path) {
@param {Hash} options
*/
export function blockHelperMissingHelper(path) {
if (!resolveHelper) { resolveHelper = requireModule('ember-handlebars/helpers/binding')['resolveHelper']; } // ES6TODO: stupid circular dep
if (!resolveHelper) {
resolveHelper = requireModule('ember-handlebars/helpers/binding')['resolveHelper'];
} // ES6TODO: stupid circular dep

var options = arguments[arguments.length - 1];

Expand Down Expand Up @@ -460,7 +466,9 @@ export function registerBoundHelper(name, fn) {
@since 1.2.0
*/
function makeBoundHelper(fn) {
if (!SimpleHandlebarsView) { SimpleHandlebarsView = requireModule('ember-handlebars/views/handlebars_bound_view')['SimpleHandlebarsView']; } // ES6TODO: stupid circular dep
if (!SimpleHandlebarsView) {
SimpleHandlebarsView = requireModule('ember-handlebars/views/handlebars_bound_view')['SimpleHandlebarsView'];
} // ES6TODO: stupid circular dep

var dependentKeys = slice.call(arguments, 1);

Expand Down
22 changes: 16 additions & 6 deletions packages/ember-handlebars/lib/helpers/binding.js
Expand Up @@ -8,7 +8,10 @@ import Ember from "ember-metal/core"; // Ember.assert, Ember.warn, uuid

import EmberHandlebars from "ember-handlebars-compiler";
import { get } from "ember-metal/property_get";
import { apply, uuid } from "ember-metal/utils";
import {
apply,
uuid
} from "ember-metal/utils";
import { fmt } from "ember-runtime/system/string";
import { create as o_create } from "ember-metal/platform";
import isNone from 'ember-metal/is_none';
Expand Down Expand Up @@ -304,7 +307,8 @@ function resolveHelper(container, name) {
var helper = container.lookup('helper:' + name);
if (!helper) {
var componentLookup = container.lookup('component-lookup:main');
Ember.assert("Could not find 'component-lookup:main' on the provided container, which is necessary for performing component lookups", componentLookup);
Ember.assert("Could not find 'component-lookup:main' on the provided container," +
" which is necessary for performing component lookups", componentLookup);

var Component = componentLookup.lookupFactory(name, container);
if (Component) {
Expand Down Expand Up @@ -375,7 +379,10 @@ function boundIfHelper(property, fn) {

fn.helperName = fn.helperName || 'boundIf';

return bind.call(context, property, fn, true, shouldDisplayIfHelperContent, shouldDisplayIfHelperContent, ['isTruthy', 'length']);
return bind.call(context, property, fn, true, shouldDisplayIfHelperContent, shouldDisplayIfHelperContent, [
'isTruthy',
'length'
]);
}

/**
Expand Down Expand Up @@ -498,7 +505,8 @@ function withHelper(context, options) {
if (arguments.length === 4) {
var keywordName, path, rootPath, normalized, contextPath;

Ember.assert("If you pass more than one argument to the with helper, it must be in the form #with foo as bar", arguments[1] === "as");
Ember.assert("If you pass more than one argument to the with helper," +
" it must be in the form #with foo as bar", arguments[1] === "as");
options = arguments[3];
keywordName = arguments[2];
path = arguments[0];
Expand Down Expand Up @@ -761,14 +769,16 @@ function bindAttrHelper(options) {
var path = attrs[attr];
var normalized;

Ember.assert(fmt("You must provide an expression as the value of bound attribute. You specified: %@=%@", [attr, path]), typeof path === 'string');
Ember.assert(fmt("You must provide an expression as the value of bound attribute." +
" You specified: %@=%@", [attr, path]), typeof path === 'string');

normalized = normalizePath(ctx, path, options.data);

var value = (path === 'this') ? normalized.root : handlebarsGet(ctx, path, options);
var type = typeOf(value);

Ember.assert(fmt("Attributes must be numbers, strings or booleans, not %@", [value]), value === null || value === undefined || type === 'number' || type === 'string' || type === 'boolean');
Ember.assert(fmt("Attributes must be numbers, strings or booleans, not %@", [value]),
value === null || value === undefined || type === 'number' || type === 'string' || type === 'boolean');

var observer;

Expand Down
3 changes: 2 additions & 1 deletion packages/ember-handlebars/lib/helpers/collection.js
Expand Up @@ -144,7 +144,8 @@ import CollectionView from "ember-views/views/collection_view";
@deprecated Use `{{each}}` helper instead.
*/
function collectionHelper(path, options) {
Ember.deprecate("Using the {{collection}} helper without specifying a class has been deprecated as the {{each}} helper now supports the same functionality.", path !== 'collection');
Ember.deprecate("Using the {{collection}} helper without specifying a class has been" +
" deprecated as the {{each}} helper now supports the same functionality.", path !== 'collection');

// If no path is provided, treat path param as options.
if (path && path.data && path.data.isRenderData) {
Expand Down
5 changes: 4 additions & 1 deletion packages/ember-handlebars/lib/helpers/debug.js
Expand Up @@ -99,4 +99,7 @@ function debuggerHelper(options) {
debugger;
}

export {logHelper, debuggerHelper};
export {
logHelper,
debuggerHelper
};
13 changes: 10 additions & 3 deletions packages/ember-handlebars/lib/helpers/each.js
Expand Up @@ -69,7 +69,11 @@ var EachView = CollectionView.extend(_Metamorph, {
!ControllerMixin.detect(content) ||
(content && content.isGenerated) ||
content instanceof ArrayController);
Ember.assert(fmt("The value that #each loops over must be an Array. You passed %@", [(ControllerMixin.detect(content) && content.get('model') !== undefined) ? fmt("'%@' (wrapped in %@)", [content.get('model'), content]) : content]), EmberArray.detect(content));
Ember.assert(fmt("The value that #each loops over must be an Array. You passed %@",
[(ControllerMixin.detect(content) &&
content.get('model') !== undefined) ?
fmt("'%@' (wrapped in %@)", [content.get('model'), content]) : content]),
EmberArray.detect(content));
},

disableContentObservers: function(callback) {
Expand Down Expand Up @@ -441,7 +445,8 @@ function eachHelper(path, options) {
var helperName = 'each';

if (arguments.length === 4) {
Ember.assert("If you pass more than one argument to the each helper, it must be in the form #each foo in bar", arguments[1] === "in");
Ember.assert("If you pass more than one argument to the each helper," +
" it must be in the form #each foo in bar", arguments[1] === "in");

var keywordName = arguments[0];

Expand All @@ -451,7 +456,9 @@ function eachHelper(path, options) {

helperName += ' ' + keywordName + ' in ' + path;

if (path === '') { path = "this"; }
if (path === '') {
path = "this";
}

options.hash.keyword = keywordName;

Expand Down
4 changes: 3 additions & 1 deletion packages/ember-handlebars/lib/helpers/partial.js
Expand Up @@ -101,5 +101,7 @@ function renderPartial(context, name, options) {

template = template || deprecatedTemplate;

template(context, { data: options.data });
template(context, {
data: options.data
});
}
3 changes: 2 additions & 1 deletion packages/ember-handlebars/lib/helpers/template.js
Expand Up @@ -13,7 +13,8 @@ import EmberHandlebars from "ember-handlebars-compiler";
@param {String} templateName the template to render
*/
export default function templateHelper(name, options) {
Ember.deprecate("The `template` helper has been deprecated in favor of the `partial` helper. Please use `partial` instead, which will work the same way.");
Ember.deprecate("The `template` helper has been deprecated in favor of the `partial` helper." +
" Please use `partial` instead, which will work the same way.");

options.helperName = options.helperName || 'template';

Expand Down

0 comments on commit 4abbd9b

Please sign in to comment.