mirror of
https://github.com/DataTables/DataTables.git
synced 2024-12-01 13:24:10 +01:00
Performance: MUCH faster removing of DOM elements in the header and body of the table - 8060 - performance testing: http://jsperf.com/remove-detach/11
This commit is contained in:
parent
1077ebcf08
commit
dbf87ff5cd
19
media/js/jquery.dataTables.js
vendored
19
media/js/jquery.dataTables.js
vendored
@ -1184,7 +1184,7 @@
|
|||||||
*/
|
*/
|
||||||
function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
|
function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
|
||||||
{
|
{
|
||||||
var i, iLen, j, jLen, k, kLen;
|
var i, iLen, j, jLen, k, kLen, n, nLocalTr;
|
||||||
var aoLocal = [];
|
var aoLocal = [];
|
||||||
var aApplied = [];
|
var aApplied = [];
|
||||||
var iColumns = oSettings.aoColumns.length;
|
var iColumns = oSettings.aoColumns.length;
|
||||||
@ -1216,12 +1216,14 @@
|
|||||||
|
|
||||||
for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
|
for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
|
||||||
{
|
{
|
||||||
|
nLocalTr = aoLocal[i].nTr;
|
||||||
|
|
||||||
/* All cells are going to be replaced, so empty out the row */
|
/* All cells are going to be replaced, so empty out the row */
|
||||||
if ( aoLocal[i].nTr )
|
if ( nLocalTr )
|
||||||
{
|
{
|
||||||
for ( k=0, kLen=aoLocal[i].nTr.childNodes.length ; k<kLen ; k++ )
|
while( (n = nLocalTr.firstChild) )
|
||||||
{
|
{
|
||||||
aoLocal[i].nTr.removeChild( aoLocal[i].nTr.childNodes[0] );
|
nLocalTr.removeChild( n );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1235,7 +1237,7 @@
|
|||||||
*/
|
*/
|
||||||
if ( aApplied[i][j] === undefined )
|
if ( aApplied[i][j] === undefined )
|
||||||
{
|
{
|
||||||
aoLocal[i].nTr.appendChild( aoLocal[i][j].cell );
|
nLocalTr.appendChild( aoLocal[i][j].cell );
|
||||||
aApplied[i][j] = 1;
|
aApplied[i][j] = 1;
|
||||||
|
|
||||||
/* Expand the cell to cover as many rows as needed */
|
/* Expand the cell to cover as many rows as needed */
|
||||||
@ -1274,7 +1276,7 @@
|
|||||||
*/
|
*/
|
||||||
function _fnDraw( oSettings )
|
function _fnDraw( oSettings )
|
||||||
{
|
{
|
||||||
var i, iLen;
|
var i, iLen, n;
|
||||||
var anRows = [];
|
var anRows = [];
|
||||||
var iRowCount = 0;
|
var iRowCount = 0;
|
||||||
var iStripes = oSettings.asStripeClasses.length;
|
var iStripes = oSettings.asStripeClasses.length;
|
||||||
@ -1431,10 +1433,9 @@
|
|||||||
if ( !oSettings.oScroll.bInfinite || !oSettings._bInitComplete ||
|
if ( !oSettings.oScroll.bInfinite || !oSettings._bInitComplete ||
|
||||||
oSettings.bSorted || oSettings.bFiltered )
|
oSettings.bSorted || oSettings.bFiltered )
|
||||||
{
|
{
|
||||||
nTrs = oSettings.nTBody.childNodes;
|
while( (n = oSettings.nTBody.firstChild) )
|
||||||
for ( i=nTrs.length-1 ; i>=0 ; i-- )
|
|
||||||
{
|
{
|
||||||
nTrs[i].parentNode.removeChild( nTrs[i] );
|
oSettings.nTBody.removeChild( n );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ function _fnBuildHead( oSettings )
|
|||||||
*/
|
*/
|
||||||
function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
|
function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
|
||||||
{
|
{
|
||||||
var i, iLen, j, jLen, k, kLen;
|
var i, iLen, j, jLen, k, kLen, n, nLocalTr;
|
||||||
var aoLocal = [];
|
var aoLocal = [];
|
||||||
var aApplied = [];
|
var aApplied = [];
|
||||||
var iColumns = oSettings.aoColumns.length;
|
var iColumns = oSettings.aoColumns.length;
|
||||||
@ -247,12 +247,14 @@ function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
|
|||||||
|
|
||||||
for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
|
for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
|
||||||
{
|
{
|
||||||
|
nLocalTr = aoLocal[i].nTr;
|
||||||
|
|
||||||
/* All cells are going to be replaced, so empty out the row */
|
/* All cells are going to be replaced, so empty out the row */
|
||||||
if ( aoLocal[i].nTr )
|
if ( nLocalTr )
|
||||||
{
|
{
|
||||||
for ( k=0, kLen=aoLocal[i].nTr.childNodes.length ; k<kLen ; k++ )
|
while( (n = nLocalTr.firstChild) )
|
||||||
{
|
{
|
||||||
aoLocal[i].nTr.removeChild( aoLocal[i].nTr.childNodes[0] );
|
nLocalTr.removeChild( n );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +268,7 @@ function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
|
|||||||
*/
|
*/
|
||||||
if ( aApplied[i][j] === undefined )
|
if ( aApplied[i][j] === undefined )
|
||||||
{
|
{
|
||||||
aoLocal[i].nTr.appendChild( aoLocal[i][j].cell );
|
nLocalTr.appendChild( aoLocal[i][j].cell );
|
||||||
aApplied[i][j] = 1;
|
aApplied[i][j] = 1;
|
||||||
|
|
||||||
/* Expand the cell to cover as many rows as needed */
|
/* Expand the cell to cover as many rows as needed */
|
||||||
@ -305,7 +307,7 @@ function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
|
|||||||
*/
|
*/
|
||||||
function _fnDraw( oSettings )
|
function _fnDraw( oSettings )
|
||||||
{
|
{
|
||||||
var i, iLen;
|
var i, iLen, n;
|
||||||
var anRows = [];
|
var anRows = [];
|
||||||
var iRowCount = 0;
|
var iRowCount = 0;
|
||||||
var iStripes = oSettings.asStripeClasses.length;
|
var iStripes = oSettings.asStripeClasses.length;
|
||||||
@ -462,10 +464,9 @@ function _fnDraw( oSettings )
|
|||||||
if ( !oSettings.oScroll.bInfinite || !oSettings._bInitComplete ||
|
if ( !oSettings.oScroll.bInfinite || !oSettings._bInitComplete ||
|
||||||
oSettings.bSorted || oSettings.bFiltered )
|
oSettings.bSorted || oSettings.bFiltered )
|
||||||
{
|
{
|
||||||
nTrs = oSettings.nTBody.childNodes;
|
while( (n = oSettings.nTBody.firstChild) )
|
||||||
for ( i=nTrs.length-1 ; i>=0 ; i-- )
|
|
||||||
{
|
{
|
||||||
nTrs[i].parentNode.removeChild( nTrs[i] );
|
oSettings.nTBody.removeChild( n );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user