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

Drop warning thrown when image equates to "" and image expression type is not used #8800

Closed
tristen opened this issue Sep 24, 2019 · 4 comments · Fixed by #8840
Closed

Drop warning thrown when image equates to "" and image expression type is not used #8800

tristen opened this issue Sep 24, 2019 · 4 comments · Fixed by #8840

Comments

@tristen
Copy link
Member

tristen commented Sep 24, 2019

mapbox-gl-js version: v1.4.0-beta.1

Question

icon-image: "" is a valid value, so I was confused when I saw this warning thrown.

Screen Shot 2019-09-24 at 4 22 25 PM

As its a common scenario to write an expression that chooses some features to use "" and others to use one, I think this sends a confusing message to a user.

Understanding the rationale behind adding it in v1.4.0 as part of the new image expression type, can we limit the warning thrown to when its in use?

Links to related documentation

@ryanhamley
Copy link
Contributor

can we limit the warning thrown to when its in use

I'm not sure I understand this part. What do you think would be the expected outcome of icon-image: "'? Should we just treat it as if icon-image was never defined?

@samanpwbb
Copy link
Contributor

samanpwbb commented Sep 24, 2019

Throwing this warning seems consistent with existing warnings, for example, when a field value is the incorrect type in a get expression. I think it's useful.

I do wonder if Mapbox GL should have separate development and production modes – where, depending on your NODE_ENV value at build time, warnings either are or are not displayed. This would eliminate the concern of console spam while freeing us up to surface more helpful warnings.

@tristen
Copy link
Member Author

tristen commented Sep 25, 2019

I'm not sure I understand this part. What do you think would be the expected outcome of icon-image: "'? Should we just treat it as if icon-image was never defined?

Yes. It should be treated as if icon-image was never defined.

Throwing this warning seems consistent with existing warnings, for example, when a field value is the incorrect type in a get expression. I think it's useful.

An incorrect type in a get expression is an example of something wrong and yeah, a warning should be thrown. However, providing "" as a possible option is a legitimate thing to do.

I do wonder if Mapbox GL should have separate development and production modes – where, depending on your NODE_ENV value at build time, warnings either are or are not displayed. This would eliminate the concern of console spam while freeing us up to surface more helpful warnings.

Yeah, that crossed my mind too (similar to how React does this) +1

@asheemmamoowala
Copy link
Contributor

However, providing "" as a possible option is a legitimate thing to do

I agree with this. Even in development mode, the error message or the styleimagemissing event for this case do not make any sense - they don't help the developer understand which layer, layer-property, or for which feature the problem exists.

More so, "" is the absence of a valid image name, where image name must be 1+ alphanumeric characters.

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

Successfully merging a pull request may close this issue.

4 participants