Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to using isExpressionFilter #43

Open
springmeyer opened this issue Apr 10, 2020 · 0 comments
Open

Move to using isExpressionFilter #43

springmeyer opened this issue Apr 10, 2020 · 0 comments

Comments

@springmeyer
Copy link
Contributor

We can likely use isExpressionFilter at

function getPropertyFromFilter(filter, properties) {
if (styleSpec.expression.isExpression(filter)) {
getPropertyFromExpression(filter, properties);
}
// Warning: Below code should put in to an else conditions,
// but since the `isExpression` can not tell it is a expression or filter syntax I put it outsied the else
// this could reduce the performance or cause some potential bugs, we must keep an eye on this.
// else {
let subFilter = [];
for (let i = 0; i < filter.length; i++) {
if (typeof filter[i] === 'object' && filter[i] instanceof Array) {
subFilter.push(filter[i]);
}
}
if (subFilter.length > 0) {
subFilter.forEach(sfilter => {
getPropertyFromFilter(sfilter, properties);
})
} else {
if (filter.length >= 3 && typeof filter[1] === 'string') {
if (filter[1].indexOf('$') === -1) {
properties.push(filter[1]);
}
}
}
// }
}
to clean up that code and avoid the commented else block.

This is getting exposed at mapbox/mapbox-gl-js#9530

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant