Allow passing undefined to ol.layer.Vector#setStyle #2638
Merged
+30
−18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR changes the
ol.layer.Vector#setStyle
to make it more consistent with the way theol.layer.Vector
constructor treats thestyle
option.Currently, if the
style
option isundefined
ornull
, theol.layer.Vector
constructor uses the default style function as the style. ThesetStyle
fails (js error) if it is passednull
orundefined
.This PR makes the constructor and the
setStyle
behave in a similar way. If the style passed to the function isnull
then anull
style (and anundefined
style function) is used. Ifundefined
is passed then the default style function is used.This allows to easily reset a vector layer to using the default style, without having to export the
ol.style.defaultStyleFunction
symbol.Please review.