Recursive append strategy
This commit is contained in:
parent
7af43e256c
commit
c274018645
@ -8,6 +8,27 @@
|
||||
/* @type {Dandelion.IDOMElement}*/
|
||||
var IDOMElement;
|
||||
|
||||
var appendR = function( container, elements )
|
||||
{
|
||||
if( elements instanceof Array )
|
||||
{
|
||||
var l = elements.length;
|
||||
for( var i = 0; i < l; i ++ )
|
||||
{
|
||||
elements[i] && appendR( container, elements[i] );
|
||||
}
|
||||
}
|
||||
else if( typeof elements == "string" )
|
||||
{
|
||||
container.appendChild( _createTextNode( elements ) );
|
||||
}
|
||||
// append child, do not do any error handling!
|
||||
else if( elements )
|
||||
{
|
||||
container.appendChild( elements );
|
||||
}
|
||||
};
|
||||
|
||||
var wrap = function ( wwith, id, wclass, elements, iKeys )
|
||||
{
|
||||
var tmp = document.createElement( wwith || "div" );
|
||||
@ -41,26 +62,9 @@
|
||||
|
||||
if( elements )
|
||||
{
|
||||
// is array?
|
||||
if(elements instanceof Array)
|
||||
{
|
||||
var l = elements.length;
|
||||
for( var i = 0; i < l; i ++ )
|
||||
{
|
||||
elements[i] && tmp.appendChild( elements[i] );
|
||||
}
|
||||
}
|
||||
// else if string
|
||||
else if( typeof elements == "string" )
|
||||
{
|
||||
tmp.appendChild(_createTextNode(elements));
|
||||
}
|
||||
// else append child, do not do any error handling!
|
||||
else if( elements )
|
||||
{
|
||||
tmp.appendChild( elements );
|
||||
}
|
||||
appendR( tmp, elements );
|
||||
}
|
||||
|
||||
return tmp;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user