From 9809d71161e15ae4d43c437bc43ccc7eb5782573 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Mon, 2 Jan 2012 19:59:52 +0000 Subject: [PATCH] Dev update: Use $.extend to copy arrays and objects for the state savings, as we don't want plug-ins to be able to muck around with the DataTables internals by mistake (even with the slice, the objects in the arrays maintain their references) --- media/js/jquery.dataTables.js | 12 ++++++------ media/src/core/core.state.js | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index e1cb89ed..c938c185 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -4235,15 +4235,15 @@ } /* Store the interesting variables */ - var i, iLen; + var i, iLen, bInfinite=oSettings.oScroll.bInfinite; var oState = { "iCreate": new Date().getTime(), - "iStart": (oSettings.oScroll.bInfinite ? 0 : oSettings._iDisplayStart), - "iEnd": (oSettings.oScroll.bInfinite ? oSettings._iDisplayLength : oSettings._iDisplayEnd), + "iStart": (bInfinite ? 0 : oSettings._iDisplayStart), + "iEnd": (bInfinite ? oSettings._iDisplayLength : oSettings._iDisplayEnd), "iLength": oSettings._iDisplayLength, - "aaSorting": oSettings.aaSorting.slice(), - "oSearch": oSettings.oPreviousSearch.sSearch, - "aoSearchCols": oSettings.aoPreSearchCols.slice(), + "aaSorting": $.extend( true, [], oSettings.aaSorting ), + "oSearch": $.extend( true, {}, oSettings.oPreviousSearch ), + "aoSearchCols": $.extend( true, [], oSettings.aoPreSearchCols ), "abVisCols": [] }; diff --git a/media/src/core/core.state.js b/media/src/core/core.state.js index b9a28be1..de668f94 100644 --- a/media/src/core/core.state.js +++ b/media/src/core/core.state.js @@ -13,15 +13,15 @@ function _fnSaveState ( oSettings ) } /* Store the interesting variables */ - var i, iLen; + var i, iLen, bInfinite=oSettings.oScroll.bInfinite; var oState = { "iCreate": new Date().getTime(), - "iStart": (oSettings.oScroll.bInfinite ? 0 : oSettings._iDisplayStart), - "iEnd": (oSettings.oScroll.bInfinite ? oSettings._iDisplayLength : oSettings._iDisplayEnd), + "iStart": (bInfinite ? 0 : oSettings._iDisplayStart), + "iEnd": (bInfinite ? oSettings._iDisplayLength : oSettings._iDisplayEnd), "iLength": oSettings._iDisplayLength, - "aaSorting": oSettings.aaSorting.slice(), - "oSearch": oSettings.oPreviousSearch.sSearch, - "aoSearchCols": oSettings.aoPreSearchCols.slice(), + "aaSorting": $.extend( true, [], oSettings.aaSorting ), + "oSearch": $.extend( true, {}, oSettings.oPreviousSearch ), + "aoSearchCols": $.extend( true, [], oSettings.aoPreSearchCols ), "abVisCols": [] };