Fixing style nits (Closes #422)

master
Luke Mahe 2015-06-22 16:00:55 +10:00 committed by Addy Osmani
parent d74aab72be
commit ae50c0f8ee
1 changed files with 17 additions and 12 deletions

View File

@ -102,7 +102,7 @@ var componentHandler = (function() {
instance[componentConfigProperty_] = registeredClass; instance[componentConfigProperty_] = registeredClass;
createdComponents_.push(instance); createdComponents_.push(instance);
// Call any callbacks the user has registered with this component type. // Call any callbacks the user has registered with this component type.
registeredClass.callbacks.forEach(function (callback) { registeredClass.callbacks.forEach(function(callback) {
callback(element); callback(element);
}); });
@ -143,8 +143,10 @@ var componentHandler = (function() {
} }
}); });
if (config.constructor.prototype.hasOwnProperty(componentConfigProperty_)) { if (config.constructor.prototype
throw 'MDL component classes must not have ' + componentConfigProperty_ + ' defined as a property.'; .hasOwnProperty(componentConfigProperty_)) {
throw 'MDL component classes must not have ' + componentConfigProperty_ +
' defined as a property.';
} }
var found = findRegisteredClass_(config.classAsString, newConfig); var found = findRegisteredClass_(config.classAsString, newConfig);
@ -182,8 +184,8 @@ var componentHandler = (function() {
/** /**
* Finds a created component by a given DOM node. * Finds a created component by a given DOM node.
* *
* @param node * @param {!Element} node
* @returns {*} * @return {*}
*/ */
function findCreatedComponentByNodeInternal(node) { function findCreatedComponentByNodeInternal(node) {
for (var n = 0; n < createdComponents_.length; n++) { for (var n = 0; n < createdComponents_.length; n++) {
@ -199,20 +201,23 @@ var componentHandler = (function() {
* Execute if found. * Execute if found.
* Remove component from createdComponents list. * Remove component from createdComponents list.
* *
* @param component * @param {*} component
*/ */
function deconstructComponentInternal(component) { function deconstructComponentInternal(component) {
if (component && if (component &&
component[componentConfigProperty_] component[componentConfigProperty_]
.classConstructor.prototype .classConstructor.prototype
.hasOwnProperty(downgradeMethod_)) { .hasOwnProperty(downgradeMethod_)) {
component[downgradeMethod_](); component[downgradeMethod_]();
var componentIndex = createdComponents_.indexOf(component); var componentIndex = createdComponents_.indexOf(component);
createdComponents_.splice(componentIndex, 1); createdComponents_.splice(componentIndex, 1);
var upgrades = component.element_.dataset.upgraded.split(','); var upgrades = component.element_.dataset.upgraded.split(',');
var componentPlace = upgrades.indexOf(component[componentConfigProperty_].classAsString); var componentPlace = upgrades.indexOf(
component[componentConfigProperty_].classAsString);
upgrades.splice(componentPlace, 1); upgrades.splice(componentPlace, 1);
component.element_.dataset.upgraded = upgrades.join(','); component.element_.dataset.upgraded = upgrades.join(',');
var ev = document.createEvent('Events'); var ev = document.createEvent('Events');
ev.initEvent('mdl-componentdowngraded', true, true); ev.initEvent('mdl-componentdowngraded', true, true);
component.element_.dispatchEvent(ev); component.element_.dispatchEvent(ev);
@ -222,7 +227,7 @@ var componentHandler = (function() {
/** /**
* Downgrade either a given node, an array of nodes, or a NodeList. * Downgrade either a given node, an array of nodes, or a NodeList.
* *
* @param nodes * @param {*} nodes
*/ */
function downgradeNodesInternal(nodes) { function downgradeNodesInternal(nodes) {
var downgradeNode = function(node) { var downgradeNode = function(node) {
@ -266,6 +271,6 @@ window.addEventListener('load', function() {
componentHandler.upgradeAllRegistered(); componentHandler.upgradeAllRegistered();
} else { } else {
componentHandler.upgradeElement = componentHandler.upgradeElement =
componentHandler.register = function () { }; componentHandler.register = function() {};
} }
}); });