mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Filter: prevent error if parseFilter returns NaN
It all depends on what the parser returns; some custom parsers may not take all situations into account
This commit is contained in:
parent
53694db90b
commit
979b3e5ddc
14
dist/js/jquery.tablesorter.widgets.js
vendored
14
dist/js/jquery.tablesorter.widgets.js
vendored
@ -1,4 +1,4 @@
|
||||
/*! tablesorter (FORK) widgets - updated 03-10-2015 (v2.21.1)*/
|
||||
/*! tablesorter (FORK) widgets - updated 03-11-2015 (v2.21.1)*/
|
||||
/* Includes: storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort */
|
||||
(function(factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
@ -495,7 +495,7 @@ ts.filter = {
|
||||
notMatch: function( c, data ) {
|
||||
if ( /^\!/.test(data.iFilter) ) {
|
||||
var indx,
|
||||
filter = ts.filter.parseFilter(c, data.iFilter.replace('!', ''), data.index, data.parsed[data.index]);
|
||||
filter = ts.filter.parseFilter(c, data.iFilter.replace('!', ''), data.index, data.parsed[data.index]) || '';
|
||||
if (ts.filter.regex.exact.test(filter)) {
|
||||
// look for exact not matches - see #628
|
||||
filter = filter.replace(ts.filter.regex.exact, '');
|
||||
@ -511,7 +511,7 @@ ts.filter = {
|
||||
exact: function( c, data ) {
|
||||
/*jshint eqeqeq:false */
|
||||
if (ts.filter.regex.exact.test(data.iFilter)) {
|
||||
var filter = ts.filter.parseFilter(c, data.iFilter.replace(ts.filter.regex.exact, ''), data.index, data.parsed[data.index]);
|
||||
var filter = ts.filter.parseFilter(c, data.iFilter.replace(ts.filter.regex.exact, ''), data.index, data.parsed[data.index]) || '';
|
||||
return data.anyMatch ? $.inArray(filter, data.rowArray) >= 0 : filter == data.iExact;
|
||||
}
|
||||
return null;
|
||||
@ -541,8 +541,8 @@ ts.filter = {
|
||||
parsed = data.parsed[index],
|
||||
// make sure the dash is for a range and not indicating a negative number
|
||||
query = data.iFilter.split( ts.filter.regex.toSplit ),
|
||||
range1 = ts.formatFloat( ts.filter.parseFilter(c, query[0].replace(ts.filter.regex.nondigit, ''), index, parsed), table ),
|
||||
range2 = ts.formatFloat( ts.filter.parseFilter(c, query[1].replace(ts.filter.regex.nondigit, ''), index, parsed), table );
|
||||
range1 = ts.formatFloat( ts.filter.parseFilter(c, query[0].replace(ts.filter.regex.nondigit, '') || '', index, parsed), table ),
|
||||
range2 = ts.formatFloat( ts.filter.parseFilter(c, query[1].replace(ts.filter.regex.nondigit, '') || '', index, parsed), table );
|
||||
// parse filter value in case we're comparing numbers (dates)
|
||||
if (parsed || c.parsers[index].type === 'numeric') {
|
||||
result = c.parsers[index].format('' + query[0], table, c.$headers.eq(index), index);
|
||||
@ -563,7 +563,7 @@ ts.filter = {
|
||||
if ( /[\?\*\|]/.test(data.iFilter) || ts.filter.regex.orReplace.test(data.filter) ) {
|
||||
var index = data.index,
|
||||
parsed = data.parsed[index],
|
||||
query = ts.filter.parseFilter(c, data.iFilter.replace(ts.filter.regex.orReplace, "|"), index, parsed);
|
||||
query = ts.filter.parseFilter(c, data.iFilter.replace(ts.filter.regex.orReplace, "|"), index, parsed) || '';
|
||||
// look for an exact match with the "or" unless the "filter-match" class is found
|
||||
if (!c.$headerIndexed[index].hasClass('filter-match') && /\|/.test(query)) {
|
||||
// show all results while using filter match. Fixes #727
|
||||
@ -581,7 +581,7 @@ ts.filter = {
|
||||
var indx,
|
||||
patternIndx = 0,
|
||||
len = data.iExact.length,
|
||||
pattern = ts.filter.parseFilter(c, data.iFilter.slice(1), data.index, data.parsed[data.index]);
|
||||
pattern = ts.filter.parseFilter(c, data.iFilter.slice(1), data.index, data.parsed[data.index]) || '';
|
||||
for (indx = 0; indx < len; indx++) {
|
||||
if (data.iExact[indx] === pattern[patternIndx]) {
|
||||
patternIndx += 1;
|
||||
|
4
dist/js/jquery.tablesorter.widgets.min.js
vendored
4
dist/js/jquery.tablesorter.widgets.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/widgets/widget-filter.min.js
vendored
2
dist/js/widgets/widget-filter.min.js
vendored
File diff suppressed because one or more lines are too long
@ -4,7 +4,7 @@
|
||||
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀▀▀▀██
|
||||
█████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀
|
||||
*/
|
||||
/*! tablesorter (FORK) widgets - updated 03-10-2015 (v2.21.1)*/
|
||||
/*! tablesorter (FORK) widgets - updated 03-11-2015 (v2.21.1)*/
|
||||
/* Includes: storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort */
|
||||
(function(factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
@ -501,7 +501,7 @@ ts.filter = {
|
||||
notMatch: function( c, data ) {
|
||||
if ( /^\!/.test(data.iFilter) ) {
|
||||
var indx,
|
||||
filter = ts.filter.parseFilter(c, data.iFilter.replace('!', ''), data.index, data.parsed[data.index]);
|
||||
filter = ts.filter.parseFilter(c, data.iFilter.replace('!', ''), data.index, data.parsed[data.index]) || '';
|
||||
if (ts.filter.regex.exact.test(filter)) {
|
||||
// look for exact not matches - see #628
|
||||
filter = filter.replace(ts.filter.regex.exact, '');
|
||||
@ -517,7 +517,7 @@ ts.filter = {
|
||||
exact: function( c, data ) {
|
||||
/*jshint eqeqeq:false */
|
||||
if (ts.filter.regex.exact.test(data.iFilter)) {
|
||||
var filter = ts.filter.parseFilter(c, data.iFilter.replace(ts.filter.regex.exact, ''), data.index, data.parsed[data.index]);
|
||||
var filter = ts.filter.parseFilter(c, data.iFilter.replace(ts.filter.regex.exact, ''), data.index, data.parsed[data.index]) || '';
|
||||
return data.anyMatch ? $.inArray(filter, data.rowArray) >= 0 : filter == data.iExact;
|
||||
}
|
||||
return null;
|
||||
@ -547,8 +547,8 @@ ts.filter = {
|
||||
parsed = data.parsed[index],
|
||||
// make sure the dash is for a range and not indicating a negative number
|
||||
query = data.iFilter.split( ts.filter.regex.toSplit ),
|
||||
range1 = ts.formatFloat( ts.filter.parseFilter(c, query[0].replace(ts.filter.regex.nondigit, ''), index, parsed), table ),
|
||||
range2 = ts.formatFloat( ts.filter.parseFilter(c, query[1].replace(ts.filter.regex.nondigit, ''), index, parsed), table );
|
||||
range1 = ts.formatFloat( ts.filter.parseFilter(c, query[0].replace(ts.filter.regex.nondigit, '') || '', index, parsed), table ),
|
||||
range2 = ts.formatFloat( ts.filter.parseFilter(c, query[1].replace(ts.filter.regex.nondigit, '') || '', index, parsed), table );
|
||||
// parse filter value in case we're comparing numbers (dates)
|
||||
if (parsed || c.parsers[index].type === 'numeric') {
|
||||
result = c.parsers[index].format('' + query[0], table, c.$headers.eq(index), index);
|
||||
@ -569,7 +569,7 @@ ts.filter = {
|
||||
if ( /[\?\*\|]/.test(data.iFilter) || ts.filter.regex.orReplace.test(data.filter) ) {
|
||||
var index = data.index,
|
||||
parsed = data.parsed[index],
|
||||
query = ts.filter.parseFilter(c, data.iFilter.replace(ts.filter.regex.orReplace, "|"), index, parsed);
|
||||
query = ts.filter.parseFilter(c, data.iFilter.replace(ts.filter.regex.orReplace, "|"), index, parsed) || '';
|
||||
// look for an exact match with the "or" unless the "filter-match" class is found
|
||||
if (!c.$headerIndexed[index].hasClass('filter-match') && /\|/.test(query)) {
|
||||
// show all results while using filter match. Fixes #727
|
||||
@ -587,7 +587,7 @@ ts.filter = {
|
||||
var indx,
|
||||
patternIndx = 0,
|
||||
len = data.iExact.length,
|
||||
pattern = ts.filter.parseFilter(c, data.iFilter.slice(1), data.index, data.parsed[data.index]);
|
||||
pattern = ts.filter.parseFilter(c, data.iFilter.slice(1), data.index, data.parsed[data.index]) || '';
|
||||
for (indx = 0; indx < len; indx++) {
|
||||
if (data.iExact[indx] === pattern[patternIndx]) {
|
||||
patternIndx += 1;
|
||||
|
@ -142,7 +142,7 @@ ts.filter = {
|
||||
notMatch: function( c, data ) {
|
||||
if ( /^\!/.test(data.iFilter) ) {
|
||||
var indx,
|
||||
filter = ts.filter.parseFilter(c, data.iFilter.replace('!', ''), data.index, data.parsed[data.index]);
|
||||
filter = ts.filter.parseFilter(c, data.iFilter.replace('!', ''), data.index, data.parsed[data.index]) || '';
|
||||
if (ts.filter.regex.exact.test(filter)) {
|
||||
// look for exact not matches - see #628
|
||||
filter = filter.replace(ts.filter.regex.exact, '');
|
||||
@ -158,7 +158,7 @@ ts.filter = {
|
||||
exact: function( c, data ) {
|
||||
/*jshint eqeqeq:false */
|
||||
if (ts.filter.regex.exact.test(data.iFilter)) {
|
||||
var filter = ts.filter.parseFilter(c, data.iFilter.replace(ts.filter.regex.exact, ''), data.index, data.parsed[data.index]);
|
||||
var filter = ts.filter.parseFilter(c, data.iFilter.replace(ts.filter.regex.exact, ''), data.index, data.parsed[data.index]) || '';
|
||||
return data.anyMatch ? $.inArray(filter, data.rowArray) >= 0 : filter == data.iExact;
|
||||
}
|
||||
return null;
|
||||
@ -188,8 +188,8 @@ ts.filter = {
|
||||
parsed = data.parsed[index],
|
||||
// make sure the dash is for a range and not indicating a negative number
|
||||
query = data.iFilter.split( ts.filter.regex.toSplit ),
|
||||
range1 = ts.formatFloat( ts.filter.parseFilter(c, query[0].replace(ts.filter.regex.nondigit, ''), index, parsed), table ),
|
||||
range2 = ts.formatFloat( ts.filter.parseFilter(c, query[1].replace(ts.filter.regex.nondigit, ''), index, parsed), table );
|
||||
range1 = ts.formatFloat( ts.filter.parseFilter(c, query[0].replace(ts.filter.regex.nondigit, '') || '', index, parsed), table ),
|
||||
range2 = ts.formatFloat( ts.filter.parseFilter(c, query[1].replace(ts.filter.regex.nondigit, '') || '', index, parsed), table );
|
||||
// parse filter value in case we're comparing numbers (dates)
|
||||
if (parsed || c.parsers[index].type === 'numeric') {
|
||||
result = c.parsers[index].format('' + query[0], table, c.$headers.eq(index), index);
|
||||
@ -210,7 +210,7 @@ ts.filter = {
|
||||
if ( /[\?\*\|]/.test(data.iFilter) || ts.filter.regex.orReplace.test(data.filter) ) {
|
||||
var index = data.index,
|
||||
parsed = data.parsed[index],
|
||||
query = ts.filter.parseFilter(c, data.iFilter.replace(ts.filter.regex.orReplace, "|"), index, parsed);
|
||||
query = ts.filter.parseFilter(c, data.iFilter.replace(ts.filter.regex.orReplace, "|"), index, parsed) || '';
|
||||
// look for an exact match with the "or" unless the "filter-match" class is found
|
||||
if (!c.$headerIndexed[index].hasClass('filter-match') && /\|/.test(query)) {
|
||||
// show all results while using filter match. Fixes #727
|
||||
@ -228,7 +228,7 @@ ts.filter = {
|
||||
var indx,
|
||||
patternIndx = 0,
|
||||
len = data.iExact.length,
|
||||
pattern = ts.filter.parseFilter(c, data.iFilter.slice(1), data.index, data.parsed[data.index]);
|
||||
pattern = ts.filter.parseFilter(c, data.iFilter.slice(1), data.index, data.parsed[data.index]) || '';
|
||||
for (indx = 0; indx < len; indx++) {
|
||||
if (data.iExact[indx] === pattern[patternIndx]) {
|
||||
patternIndx += 1;
|
||||
|
Loading…
Reference in New Issue
Block a user