-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fix removal of render features from vector source #15827
Fix removal of render features from vector source #15827
Conversation
📦 Preview the website for this branch here: https://deploy-preview-15827--ol-site.netlify.app/. |
04b65d9
to
7e23b0a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @sebakerckhof. I added a few suggestions.
src/ol/source/Vector.js
Outdated
if (!featureChangeKeys) { | ||
return; | ||
if (featureChangeKeys) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually keep the happy path aligned as far left as possible, so it would be preferable to keep the logic that returns early when there ar no featureChangeKeys
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we can't return early because renderfeatures don't have change keys.
I could check for !featureChangeKeys && feature instanceof Feature
though if you prefer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please, that would make the code easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, an early return also doesn't make sense here since !featureChangeKeys && feature instanceof Feature
can never happen anymore due to the introduction of the uidIndex
check at the top.
So I just removed the if clause and added optional chaining on the featureChangeKeys.foreach
.
Co-authored-by: Andreas Hocevar <andreas.hocevar@gmail.com>
0eb78f7
to
a64efb0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @sebakerckhof
Render features were not fully removed because they don't have change keys and can be arrays.
I look at the uindex now instead of the change keys