mirror of
https://github.com/DataTables/DataTables.git
synced 2025-01-19 12:52:11 +01:00
Performance - HTML decode uses DOM directly rather than jQuery to speed things up
- Based on the discussion in forum thread 16961 and the results from http://jsperf.com/html-decode I've updated how the HTML decode for filtering is done to bypass jQuery and use DOM methods directly. It is more code but it is also much faster.
This commit is contained in:
parent
74a78b2010
commit
4d6081c3d2
@ -1 +1 @@
|
||||
490f897e3bdc5c679f8a3ecf2522886d293f5c0f
|
||||
e7fe17ae3c694b0af5e5a7c710eb775e19794fc8
|
||||
|
13
media/js/jquery.dataTables.js
vendored
13
media/js/jquery.dataTables.js
vendored
@ -2454,7 +2454,8 @@
|
||||
|
||||
|
||||
|
||||
var __filter_div = $('<div>');
|
||||
var __filter_div = $('<div>')[0];
|
||||
var __filter_div_textContent = __filter_div.textContent !== undefined;
|
||||
|
||||
// Update the filtering data for each row if needed (by invalidation or first run)
|
||||
function _fnFilterData ( settings )
|
||||
@ -2488,9 +2489,15 @@
|
||||
}
|
||||
|
||||
// If it looks like there is an HTML entity in the string,
|
||||
// attempt to decode it so sorting works as expected
|
||||
// attempt to decode it so sorting works as expected. Note that
|
||||
// we could use a single line of jQuery to do this, but the DOM
|
||||
// method used here is much faster http://jsperf.com/html-decode
|
||||
if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
|
||||
cellData = __filter_div.html( cellData ).text();
|
||||
__filter_div.innerHTML = cellData;
|
||||
cellData = __filter_div_textContent ?
|
||||
__filter_div.textContent :
|
||||
__filter_div.innerText;
|
||||
cellData = cellData.replace(/[\r\n]/g, '');
|
||||
}
|
||||
|
||||
filterData.push( cellData );
|
||||
|
Loading…
x
Reference in New Issue
Block a user