Skip to content
This repository has been archived by the owner on Nov 8, 2018. It is now read-only.

Commit

Permalink
'in' Filters with too many elements fail with "Uncaught RangeError: M…
Browse files Browse the repository at this point in the history
…aximum call stack size exceeded"

Fixes mapbox/mapbox-gl-js#1782
  • Loading branch information
peckjon committed Jan 12, 2016
1 parent 94cbae8 commit 814cd0b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ var operators = {
'<=': strictInfix('<='),
'>=': strictInfix('>='),
'in': function(_, key) {
return Array.prototype.slice.call(arguments, 2).map(function(value) {
return '(' + operators['=='](_, key, value) + ')';
}).join('||') || 'false';
return (key==='$type')?
Array.prototype.slice.call(arguments, 2).map(function(value) {
return '(' + operators['=='](_, key, value) + ')';
}).join('||') || 'false'
:
JSON.stringify(Array.prototype.slice.call(arguments, 2))+'.indexOf(p['+JSON.stringify(key)+'])>=0';
},
'!in': function() {
return '!(' + operators.in.apply(this, arguments) + ')';
Expand Down

0 comments on commit 814cd0b

Please sign in to comment.