Check that the filter is not undefined before encoding/decoding it.

If we include undefined filter values in the encoding/decoding,
then we store 'undefined' as the value in the cookie. When this
gets parsed out, it's treated as an actual value. This will likely
not match anything resulting in the initial filtering to filter out
all results.
This commit is contained in:
tschilling 2016-01-19 15:10:22 -05:00
parent f469d399f7
commit 4cb15889d7
9 changed files with 38 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/*! tablesorter (FORK) - updated 01-15-2016 (v2.25.2)*/ /*! tablesorter (FORK) - updated 01-19-2016 (v2.25.2)*/
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */ /* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
(function(factory) { (function(factory) {
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
@ -3701,7 +3701,9 @@
mode = encode ? encodeURIComponent : decodeURIComponent, mode = encode ? encodeURIComponent : decodeURIComponent,
len = filters.length; len = filters.length;
for ( indx = 0; indx < len; indx++ ) { for ( indx = 0; indx < len; indx++ ) {
filters[ indx ] = mode( filters[ indx ] ); if ( typeof filters[ indx ] !== 'undefined' ) {
filters[ indx ] = mode( filters[ indx ] );
}
} }
return filters; return filters;
}, },

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
/*! tablesorter (FORK) - updated 01-15-2016 (v2.25.2)*/ /*! tablesorter (FORK) - updated 01-19-2016 (v2.25.2)*/
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */ /* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
(function(factory) { (function(factory) {
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
@ -983,7 +983,9 @@
mode = encode ? encodeURIComponent : decodeURIComponent, mode = encode ? encodeURIComponent : decodeURIComponent,
len = filters.length; len = filters.length;
for ( indx = 0; indx < len; indx++ ) { for ( indx = 0; indx < len; indx++ ) {
filters[ indx ] = mode( filters[ indx ] ); if ( typeof filters[ indx ] !== 'undefined' ) {
filters[ indx ] = mode( filters[ indx ] );
}
} }
return filters; return filters;
}, },

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*/ */
/*! tablesorter (FORK) - updated 01-15-2016 (v2.25.2)*/ /*! tablesorter (FORK) - updated 01-19-2016 (v2.25.2)*/
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */ /* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
(function(factory) { (function(factory) {
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
@ -3707,7 +3707,9 @@
mode = encode ? encodeURIComponent : decodeURIComponent, mode = encode ? encodeURIComponent : decodeURIComponent,
len = filters.length; len = filters.length;
for ( indx = 0; indx < len; indx++ ) { for ( indx = 0; indx < len; indx++ ) {
filters[ indx ] = mode( filters[ indx ] ); if ( typeof filters[ indx ] !== 'undefined' ) {
filters[ indx ] = mode( filters[ indx ] );
}
} }
return filters; return filters;
}, },

View File

@ -4,7 +4,7 @@
*/ */
/*! tablesorter (FORK) - updated 01-15-2016 (v2.25.2)*/ /*! tablesorter (FORK) - updated 01-19-2016 (v2.25.2)*/
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */ /* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
(function(factory) { (function(factory) {
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
@ -989,7 +989,9 @@
mode = encode ? encodeURIComponent : decodeURIComponent, mode = encode ? encodeURIComponent : decodeURIComponent,
len = filters.length; len = filters.length;
for ( indx = 0; indx < len; indx++ ) { for ( indx = 0; indx < len; indx++ ) {
filters[ indx ] = mode( filters[ indx ] ); if ( typeof filters[ indx ] !== 'undefined' ) {
filters[ indx ] = mode( filters[ indx ] );
}
} }
return filters; return filters;
}, },

View File

@ -615,7 +615,9 @@
mode = encode ? encodeURIComponent : decodeURIComponent, mode = encode ? encodeURIComponent : decodeURIComponent,
len = filters.length; len = filters.length;
for ( indx = 0; indx < len; indx++ ) { for ( indx = 0; indx < len; indx++ ) {
filters[ indx ] = mode( filters[ indx ] ); if ( typeof filters[ indx ] !== 'undefined' ) {
filters[ indx ] = mode( filters[ indx ] );
}
} }
return filters; return filters;
}, },

View File

@ -158,6 +158,18 @@ jQuery(function($){
assert.deepEqual( range( c, 'a-b-c,100' ), [ 0,1,2,3,4,5,6,7,8,9 ], 'text with dashes & commas -> all columns' ); assert.deepEqual( range( c, 'a-b-c,100' ), [ 0,1,2,3,4,5,6,7,8,9 ], 'text with dashes & commas -> all columns' );
}); });
QUnit.test( 'Filter process filters', function(assert) {
expect(2);
var processFilters = this.ts.filter.processFilters,
filters = [],
results = [];
filters[1] = 5, filters[2] = 'test', filters[3] = true;
results[1] = '5', results[2] = 'test', results[3] = 'true';
assert.deepEqual( processFilters( filters, true ), results );
assert.deepEqual( processFilters( filters, false ), results );
});
QUnit.test( 'Filter searches', function(assert) { QUnit.test( 'Filter searches', function(assert) {
var ts = this.ts, var ts = this.ts,
c = this.c, c = this.c,