Skip to content

Instantly share code, notes, and snippets.

@eunomie
Created April 17, 2012 14:38
Show Gist options
  • Save eunomie/2406396 to your computer and use it in GitHub Desktop.
Save eunomie/2406396 to your computer and use it in GitHub Desktop.
inconsistent code style
/**
* @param {*} input to create the G with.
* @param {string|Element|Node=} opt_mod elemnt to look under.
* @constructor
* @return {G} the G object.
*/
G = function(input, opt_mod) {
if (input.constructor == G) // if with one statement and no {}
return /** @type {G} */(input);
if (goog.isString(opt_mod)) { // if with one statement but {}
opt_mod = G.elsBySelector(/** @type {string} */(opt_mod))[0];
}
if (input.nodeType) // if without {}
input = [input];
else if (goog.isString(input)) { // but else if with {}
if (input.charAt(0) == '<') {
input = [goog.dom.htmlToDocumentFragment(input)];
} else { // else and } on the same line
input = G.elsBySelector(input, opt_mod);
}
if (!input) {
input = [];
}
} // but } and else not on the same line
else if (!input) {
input = [];
}
if (!goog.isArrayLike(input)) {
input = [input];
}
return /** @type {G} */(new G.init(/** @type {{length: number}} */(input)));
};
if (!goog.isDef(opt_selector))
return true;
if (goog.isFunction(opt_selector)) {
return opt_selector(element);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment