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

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)

This commit is contained in:
Allan Jardine 2012-01-02 19:59:52 +00:00
parent a4c7ac222a
commit 9809d71161
2 changed files with 12 additions and 12 deletions

View File

@ -4235,15 +4235,15 @@
} }
/* Store the interesting variables */ /* Store the interesting variables */
var i, iLen; var i, iLen, bInfinite=oSettings.oScroll.bInfinite;
var oState = { var oState = {
"iCreate": new Date().getTime(), "iCreate": new Date().getTime(),
"iStart": (oSettings.oScroll.bInfinite ? 0 : oSettings._iDisplayStart), "iStart": (bInfinite ? 0 : oSettings._iDisplayStart),
"iEnd": (oSettings.oScroll.bInfinite ? oSettings._iDisplayLength : oSettings._iDisplayEnd), "iEnd": (bInfinite ? oSettings._iDisplayLength : oSettings._iDisplayEnd),
"iLength": oSettings._iDisplayLength, "iLength": oSettings._iDisplayLength,
"aaSorting": oSettings.aaSorting.slice(), "aaSorting": $.extend( true, [], oSettings.aaSorting ),
"oSearch": oSettings.oPreviousSearch.sSearch, "oSearch": $.extend( true, {}, oSettings.oPreviousSearch ),
"aoSearchCols": oSettings.aoPreSearchCols.slice(), "aoSearchCols": $.extend( true, [], oSettings.aoPreSearchCols ),
"abVisCols": [] "abVisCols": []
}; };

View File

@ -13,15 +13,15 @@ function _fnSaveState ( oSettings )
} }
/* Store the interesting variables */ /* Store the interesting variables */
var i, iLen; var i, iLen, bInfinite=oSettings.oScroll.bInfinite;
var oState = { var oState = {
"iCreate": new Date().getTime(), "iCreate": new Date().getTime(),
"iStart": (oSettings.oScroll.bInfinite ? 0 : oSettings._iDisplayStart), "iStart": (bInfinite ? 0 : oSettings._iDisplayStart),
"iEnd": (oSettings.oScroll.bInfinite ? oSettings._iDisplayLength : oSettings._iDisplayEnd), "iEnd": (bInfinite ? oSettings._iDisplayLength : oSettings._iDisplayEnd),
"iLength": oSettings._iDisplayLength, "iLength": oSettings._iDisplayLength,
"aaSorting": oSettings.aaSorting.slice(), "aaSorting": $.extend( true, [], oSettings.aaSorting ),
"oSearch": oSettings.oPreviousSearch.sSearch, "oSearch": $.extend( true, {}, oSettings.oPreviousSearch ),
"aoSearchCols": oSettings.aoPreSearchCols.slice(), "aoSearchCols": $.extend( true, [], oSettings.aoPreSearchCols ),
"abVisCols": [] "abVisCols": []
}; };