diff --git a/src/style-spec/feature_filter/convert.js b/src/style-spec/feature_filter/convert.js index 574c64779d1..1998eabc87a 100644 --- a/src/style-spec/feature_filter/convert.js +++ b/src/style-spec/feature_filter/convert.js @@ -92,7 +92,7 @@ function _convertFilter(filter: FilterSpecification, expectedTypes: ExpectedType return ['any'].concat(children); } else if (op === 'all') { const children = (filter: any).slice(1).map(f => _convertFilter(f, expectedTypes)); - return ['all'].concat(children); + return children.length > 1 ? ['all'].concat(children) : [].concat(...children); } else if (op === 'none') { return ['!', _convertFilter(['any'].concat(filter.slice(1)), {})]; } else if (op === 'in') { diff --git a/test/unit/style-spec/feature_filter.test.js b/test/unit/style-spec/feature_filter.test.js index d1624ca4487..a63ab9f3757 100644 --- a/test/unit/style-spec/feature_filter.test.js +++ b/test/unit/style-spec/feature_filter.test.js @@ -100,6 +100,47 @@ test('convert legacy filters to expressions', t => { t.end(); }); + t.test('foople barp garp', (t) => { + const filter = [ + "all", + [ + "in", + "$type", + "Polygon", + "LineString", + "Point" + ], + [ + "all", + ["in", "type", "island"] + ] + ]; + + const expected = [ + "all", + [ + "match", + ["geometry-type"], + ["Polygon", "LineString", "Point"], + true, + false + ], + [ + "match", + ["get", "type"], + ["island"], + true, + false + ] + ]; + + const converted = convertFilter(filter); + // console.log(JSON.stringify(converted, null, 2)); + console.log(converted[2]) + t.same(converted, expected); + t.end(); + }); + t.end(); });