From b1d88c1c91e0edd35c46654766d5f3502f79d730 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Sat, 6 Apr 2013 09:44:52 +0100 Subject: [PATCH] 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. --- media/src/api/api.methods.js | 9 ++++----- media/src/core/core.constructor.js | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/media/src/api/api.methods.js b/media/src/api/api.methods.js index 74e70275..68aca8e2 100644 --- a/media/src/api/api.methods.js +++ b/media/src/api/api.methods.js @@ -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 diff --git a/media/src/core/core.constructor.js b/media/src/core/core.constructor.js index f067c030..15354227 100644 --- a/media/src/core/core.constructor.js +++ b/media/src/core/core.constructor.js @@ -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 } );