-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
mapbox-gl-js version: 1.9.0
Steps to Trigger Behavior
- Use an
in
expression that has the needle as null with the haystack as an array containing null - e.g. `['in', null, ["literal", [1,2,3,null,5] ]] - The expression will always return false
Link to Demonstration
https://jsbin.com/qepihirize/edit?js,output
Each circle is a needle of a different type, they should all be black as they are within the haystack.
Expected Behavior
Be able to find null
within an array
Actual Behavior
in
will always return false
When implementing the index-of
expression (#9443) I noticed that in
will always return false if the needle is null
even if the haystack is an array of values that contains a null.
The line that is causing this issue is below, it appears that it was changed in #9295 to allow false but still filters out null
and undefined
and shortcuts to return false.
if (needle == null || !haystack) return false; |
I'd expect index-of
and in
to work the same way, just so we don't get conflicting answers for the below edge case:
['in', null, ["literal", [1,2,3,null,5] ]] // false
["==", ['index-of', null, ["literal", [1,2,3,null,5] ]], -1] // true
I can fix this as part of my PR #9450 but just wanted to confirm that this wasn't another reason why we have this behaviour.