Skip to content

Commit

Permalink
Deep cloning of cluster properties. Closes mapbox#215
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarfonts committed Mar 18, 2024
1 parent fff7326 commit 5b0a9e1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,11 @@ export default class Supercluster {
_map(data, i, clone) {
if (data[i + OFFSET_NUM] > 1) {
const props = this.clusterProps[data[i + OFFSET_PROP]];
return clone ? Object.assign({}, props) : props;
return clone ? structuredClone(props) : props;
}
const original = this.points[data[i + OFFSET_ID]].properties;
const result = this.options.map(original);
return clone && result === original ? Object.assign({}, result) : result;
return clone && result === original ? structuredClone({}, result) : result;
}
}

Expand Down

0 comments on commit 5b0a9e1

Please sign in to comment.