1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-12-01 13:24:10 +01:00

Performance: Read the style.width property for the restore width and

apply that.

- This is much faster than the previous method of using $(this).width()
  since there is no longer an invalidation and getComputedStyle
  calculation. It just uses the value that is available in style.width,
  which might very well be empty (if the style attribute is used with a
  width property defined is it not empty).

- This also improves accuracy since it is the original that is restored,
  and not the calculated size.

- See http://datatables.net/forums/discussion/14811 for the discussion
  for this change.

- Thanks to `krzycho` for the discussion and suggestions.
This commit is contained in:
Allan Jardine 2013-04-06 09:44:52 +01:00
parent ad0e08585f
commit b1d88c1c91
2 changed files with 5 additions and 6 deletions

View File

@ -559,11 +559,10 @@ this.fnDestroy = function ( bRemove )
}
}
/* Restore the width of the original table */
if ( oSettings.oFeatures.bAutoWidth === true )
{
oSettings.nTable.style.width = _fnStringToCss(oSettings.sDestroyWidth);
}
/* Restore the width of the original table - was read from the style property,
* so we can restore directly to that
*/
oSettings.nTable.style.width = oSettings.sDestroyWidth;
/* If the were originally stripe classes - then we add them back here. Note
* this is not fool proof (for example if not all rows had stripe classes - but

View File

@ -76,7 +76,7 @@ var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
"nTable": this,
"oApi": _that.oApi,
"oInit": oInit,
"sDestroyWidth": $(this).width(),
"sDestroyWidth": $(this)[0].style.width,
"sInstance": sId,
"sTableId": sId
} );