Skip to content

Instantly share code, notes, and snippets.

@middric
Created July 30, 2012 16:14
Show Gist options
  • Save middric/3208137 to your computer and use it in GitHub Desktop.
Save middric/3208137 to your computer and use it in GitHub Desktop.
domBuilder
var domBuilder = function(h, i, j, k, l) {
while(l=i.shift()) {
if ((j = l[0]) && j.exec) {
k = document.createElement((j+"").split('/')[1]);
for(j in l[1]) {
k[j] = l[1][j]
}
h.appendChild(k);
h = k;
} else {
l[0] ? h.innerHTML = l : h = h.parentNode
}
}
};
var a=function(c,e,a,d,b){for(;b=e.shift();)if((a=b[0])&&a.exec){d=document.createElement((a+"").split("/")[1]);for(a in b[1])d[a]=b[1][a];c.appendChild(d);c=d}else b[0]?c.innerHTML=b:c=c.parentNode}
domBuilder(document.body, [
[/HTML/],
[/HEAD/],
[/TITLE/],
"Wouldn't this be cool?",
[],
[],
[/BODY/],
[/DIV/, {id: "container"}],
"Hello, world",
[],
[],
[]
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment