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

Fix fallback conditional for filter validation #11475

Merged
merged 3 commits into from
Mar 10, 2022
Merged

Conversation

ryanhamley
Copy link
Contributor

Launch Checklist

@ryanhamley ryanhamley requested a review from ansis February 4, 2022 19:45
Copy link
Member

@mourner mourner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test for this so that this doesn't regress again after a potential refactoring of validation code?

Copy link
Contributor

@SnailBones SnailBones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Just one thought: your changes to validate_filter.js are going to trigger a merge conflict with #11529, which also makes a change addressing the readability of that line. So perhaps consider reverting that change to simplify merging?

@@ -13,7 +13,7 @@ export default function validateFilter(options) {
return validateExpression(extend({}, options, {
expressionContext: 'filter',
// We default to a layerType of `fill` because that points to a non-dynamic filter definition within the style-spec.
valueSpec: options.styleSpec[`filter_${layerType || 'fill'}`]
valueSpec: options.styleSpec[`filter_${layerType}`] || options.styleSpec[`filter_fill`]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement to readability! But I think that this change will have a conflict with the different approach @stepankuzmin is taking here.

Maybe consider reverting this to skip resolving the merge conflict?

Suggested change
valueSpec: options.styleSpec[`filter_${layerType}`] || options.styleSpec[`filter_fill`]
valueSpec: options.styleSpec[`filter_${layerType || 'fill'}`]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out @SnailBones I reverted this change

@ryanhamley ryanhamley self-assigned this Mar 10, 2022
@ryanhamley ryanhamley merged commit 74d8aec into main Mar 10, 2022
@ryanhamley ryanhamley deleted the fix-filter-validation branch March 10, 2022 00:06
ahocevar pushed a commit to ahocevar/mapbox-gl-js that referenced this pull request Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants