Skip to content

Move to using isExpressionFilter #43

@springmeyer

Description

@springmeyer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions