Skip to content

Commit

Permalink
Accept undefined in setFilter
Browse files Browse the repository at this point in the history
This makes `setFilter` consistent with `setLayoutProperty` and
`setPaintProperty`, both of which accept either `null` or `undefined` to
unset the property value.

Helps diffing/setState, because in order for the input to setState
to be valid style JSON, we can't have `filter: null`, but rather need to
omit the `filter` property.  Without having `setFilter` accept `null`,
we'd have to (hackily) replace `undefined` with `null` in the style
diff results
  • Loading branch information
Anand Thakker committed Nov 16, 2016
1 parent 23b4676 commit 36516f7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion js/style/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ class Style extends Evented {

const layer = this.getLayer(layerId);

if (filter !== null && this._validate(validateStyle.filter, `layers.${layer.id}.filter`, filter)) return;
if (filter !== null && filter !== undefined && this._validate(validateStyle.filter, `layers.${layer.id}.filter`, filter)) return;

if (util.deepEqual(layer.filter, filter)) return;
layer.filter = util.clone(filter);
Expand Down

0 comments on commit 36516f7

Please sign in to comment.