Skip to content

Instantly share code, notes, and snippets.

@leviwheatcroft
Created May 7, 2012 06:23
Show Gist options
  • Save leviwheatcroft/2626238 to your computer and use it in GitHub Desktop.
Save leviwheatcroft/2626238 to your computer and use it in GitHub Desktop.
rendAr plugin v0.4
Array.implement({
rendAr: function() {
var el = [];
this.each(function(item) {
if (typeOf(item) == 'element') el.push(item);
else if (typeOf(item) == 'string') el.push(new Element(item));
else if (typeOf(item) == 'elements') item.each(function(i) {el.push(i);});
else if (typeOf(item) == 'array') el[el.length - 1].adopt(item.rendAr());
else if (typeOf(item) == 'object') el[el.length - 1].set(item);
});
return el[1] ? new Elements(el) : el[0];
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment