Skip to content

Parse conditionals more reliably #30

@aparlato

Description

@aparlato

See https://github.com/stamen/mapbox-gl-style-design-system/blob/main/src/styles/expandLayers.js#L76-L94 and https://github.com/stamen/mapbox-gl-style-design-system/blob/main/src/styles/expandLayers.js#L131-L137

There's logic in expandLayers that finds properties and property values within the conditions of match and case expressions. It does this fairly naively right now which means it's fragile.

For case, it finds the property through finding a lookup expression, then the property values by filtering down to everything that's not a property and not an expression. For match it's more reliable to find properties, but we have some naive handling to parse through instances where we look at the length of a property (eg [length, [get, ref]]).

We should see if we can parse these expressions more reliably. It would be worth diving deeper into the style spec to see if there's functionality there we can pull out, but otherwise, we might expand these functions to account for more scenarios.

Metadata

Metadata

Assignees

Labels

enablementallows us to something otherwise impossibleenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions