Skip to content

Commit

Permalink
Filter: Do not return altered filters. Fixes #1237
Browse files Browse the repository at this point in the history
  • Loading branch information
Mottie committed Jun 28, 2016
1 parent e96879b commit 53bc869
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions js/widgets/widget-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,14 +629,16 @@
// encode or decode filters for storage; see #1026
processFilters: function( filters, encode ) {
var indx,
// fixes #1237; previously returning an encoded "filters" value
result = [],
mode = encode ? encodeURIComponent : decodeURIComponent,
len = filters.length;
for ( indx = 0; indx < len; indx++ ) {
if ( filters[ indx ] ) {
filters[ indx ] = mode( filters[ indx ] );
result[ indx ] = mode( filters[ indx ] );
}
}
return filters;
return result;
},
setDefaults: function( table, c, wo ) {
var isArray, saved, indx, col, $filters,
Expand Down
5 changes: 3 additions & 2 deletions testing/testing-widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,9 @@ jQuery(function($){
var processFilters = this.ts.filter.processFilters,
filters = [],
results = [];
filters[1] = 5, filters[2] = 'test', filters[3] = true, filters[4] = null;
results[1] = '5', results[2] = 'test', results[3] = 'true', results[4] = null;
filters[1] = 5; filters[2] = 'test'; filters[3] = true; filters[4] = null;
results[1] = '5'; results[2] = 'test'; results[3] = 'true';
// filters[4] will now become undefined within results - see #1237

assert.deepEqual( processFilters( filters, true ), results );
assert.deepEqual( processFilters( filters, false ), results );
Expand Down

0 comments on commit 53bc869

Please sign in to comment.