1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-03-15 16:29:16 +01:00

Merge pull request #86 from timtucker/patch-3

Improve dom iteration performance in _fnApplyToChildren
This commit is contained in:
Allan Jardine 2012-09-02 01:34:13 -07:00
commit dd2f084794

View File

@ -1,5 +1,4 @@
/** /**
* Add any control elements for the table - specifically scrolling * Add any control elements for the table - specifically scrolling
* @param {object} oSettings dataTables settings object * @param {object} oSettings dataTables settings object
@ -484,27 +483,31 @@ function _fnScrollDraw ( o )
*/ */
function _fnApplyToChildren( fn, an1, an2 ) function _fnApplyToChildren( fn, an1, an2 )
{ {
var index=0, var index=0, i=0, iLen=an1.length;
i, iLen, j, jLen; var nNode1, nNode2;
for ( i=0, iLen=an1.length ; i<iLen ; i++ ) while ( i < iLen )
{ {
for ( j=0, jLen=an1[i].childNodes.length ; j<jLen ; j++ ) nNode1 = an1[i].firstChild;
nNode2 = an2 ? an2[i].firstChild : null;
while ( nNode1 )
{ {
if ( an1[i].childNodes[j].nodeType == 1 ) if ( nNode1.nodeType === 1 )
{ {
if ( an2 ) if ( an2 )
{ {
fn( an1[i].childNodes[j], an2[i].childNodes[j], index ); fn( nNode1, nNode2, index );
} }
else else
{ {
fn( an1[i].childNodes[j], index ); fn( nNode1, index );
} }
index++; index++;
} }
nNode1 = nNode1.nextSibling;
nNode2 = an2 ? nNode2.nextSibling : null;
} }
i++;
} }
} }