Return shallow clones of features, because the hashes may change

If we return the original feature, and then change the hash later as the
feature merges with another, d3 won't exit/enter because it is joining
on the new hash, not the originally hash.
This commit is contained in:
Bryan Housel
2018-08-25 00:12:21 -04:00
parent a9aca707b6
commit 7241e07344

View File

@@ -1,3 +1,4 @@
import _clone from 'lodash-es/clone';
import _find from 'lodash-es/find';
import _isEqual from 'lodash-es/isEqual';
import _forEach from 'lodash-es/forEach';
@@ -172,7 +173,10 @@ export default {
var hash = feature.__featurehash__;
if (seen[hash]) continue;
seen[hash] = true;
results.push(feature);
// return a shallow clone, because the hash may change
// later if this feature gets merged with another
results.push(_clone(feature));
}
}