Skip to content

Commit ef7ae1b

Browse files
committed
Fixes clone
1 parent ebac06e commit ef7ae1b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

2019/18/infinite-grid.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class InfiniteGrid {
55
* @param {Object} [options.string_map] - Map grid values to strings.
66
*/
77
constructor({ defaultFactory = (x, y) => 0, string_map = {} } = {}) {
8-
this.defaultFactory = defaultFactory;
8+
this.defaultFactory = defaultFactory.bind(this);
99
this.string_map = string_map;
1010
this.grid = new Map();
1111
this.max_x = -Infinity;
@@ -106,6 +106,7 @@ class InfiniteGrid {
106106
for (let [key, val] of this.grid) {
107107
new_map.set(key, typeof val === 'object' ? JSON.parse(JSON.stringify(val)) : val);
108108
}
109+
infinite_grid_clone.defaultFactory = this.defaultFactory.bind(this);
109110
infinite_grid_clone.string_map = JSON.parse(JSON.stringify(this.string_map));
110111
infinite_grid_clone.grid = new_map;
111112
infinite_grid_clone.max_x = this.max_x;

0 commit comments

Comments
 (0)