mirror of
https://github.com/DataTables/DataTables.git
synced 2025-03-15 16:29:16 +01:00
Fix: Percentage columns detected as date columns in Chrome
* V8 strips unknown characters not only at the start of a string given to Date.parse() but also at the end. So `10%` (for example) was being detected as a date type. * This fixes DataTables/DataTables #354
This commit is contained in:
parent
84686a5b30
commit
b2509005ab
@ -1 +1 @@
|
||||
82b2580b26e160220f92abfa51c7cbca2b53b17a
|
||||
0e5a4d7a663a0a88e12b47d08883a381fca7d1e2
|
||||
|
11
media/js/jquery.dataTables.js
vendored
11
media/js/jquery.dataTables.js
vendored
@ -105,7 +105,8 @@
|
||||
var _re_dic = {};
|
||||
var _re_new_lines = /[\r\n]/g;
|
||||
var _re_html = /<.*?>/g;
|
||||
var _re_date_start = /^[\d\+\-a-zA-Z]/;
|
||||
var _re_date_start = /^[\w\+\-]/;
|
||||
var _re_date_end = /[\w\+\-]$/;
|
||||
|
||||
// Escape regular expression special characters
|
||||
var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' );
|
||||
@ -13980,10 +13981,10 @@
|
||||
// Dates (only those recognised by the browser's Date.parse)
|
||||
function ( d, settings )
|
||||
{
|
||||
// V8 will remove any unknown characters at the start of the expression,
|
||||
// leading to false matches such as `$245.12` being a valid date. See
|
||||
// forum thread 18941 for detail.
|
||||
if ( d && ! _re_date_start.test(d) ) {
|
||||
// V8 will remove any unknown characters at the start and end of the
|
||||
// expression, leading to false matches such as `$245.12` or `10%` being
|
||||
// a valid date. See forum thread 18941 for detail.
|
||||
if ( d && ( ! _re_date_start.test(d) || ! _re_date_end.test(d) ) ) {
|
||||
return null;
|
||||
}
|
||||
var parsed = Date.parse(d);
|
||||
|
Loading…
x
Reference in New Issue
Block a user