From f2133c79df9abd2177f6dfb393a42905e211908f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Rivi=C3=A8re?= Date: Mon, 6 Jul 2020 21:49:29 +0200 Subject: [PATCH 1/5] prevent an infinite loop The situation happens in force simulations when a point is horribly far (maybe because of a programming error, or because we set the wrong parameters on an experimental force). Then forceCollide calls quadtree(nodes, x,,y), which tries to cover by repeatedly doubling z=0. This ends up crashing the browser. --- src/cover.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cover.js b/src/cover.js index a981a3d..e1d47cd 100644 --- a/src/cover.js +++ b/src/cover.js @@ -16,7 +16,7 @@ export default function(x, y) { // Otherwise, double repeatedly to cover. else { - var z = x1 - x0, + var z = x1 - x0 || 1, node = this._root, parent, i; From 702ea2c1a8c4beda244f4f1ffe766a96975a7798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Rivi=C3=A8re?= Date: Mon, 6 Jul 2020 22:00:25 +0200 Subject: [PATCH 2/5] crash test --- test/cover-test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/cover-test.js b/test/cover-test.js index cd49d09..08c42a0 100644 --- a/test/cover-test.js +++ b/test/cover-test.js @@ -77,3 +77,8 @@ tape("quadtree.cover(x, y) does not wrap the root node if it is undefined", func test.equal(q.copy().cover(-3, -3).root(), undefined); test.end(); }); + +tape("quadtree.cover() does not crash on huge values", function(test) { + d3_quadtree.quadtree([[1e23, 0]]); + test.end(); +}); From c7baf2d07c55572cc0631a40ed0dd9f6272ff51a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Rivi=C3=A8re?= Date: Fri, 10 Jul 2020 21:34:42 +0200 Subject: [PATCH 3/5] deliberate ES6 syntax (rationale: don't let people install @2 in a build system that will not alert them that we have moved to ES6, only to cause trouble with a later release.) --- src/add.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/add.js b/src/add.js index ac7c4d1..985adfc 100644 --- a/src/add.js +++ b/src/add.js @@ -1,5 +1,5 @@ export default function(d) { - var x = +this._x.call(null, d), + const x = +this._x.call(null, d), y = +this._y.call(null, d); return add(this.cover(x, y), x, y, d); } From ba5d3534d2b7e64476c76b2f3a5dcb6594d966c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Rivi=C3=A8re?= Date: Fri, 10 Jul 2020 21:34:52 +0200 Subject: [PATCH 4/5] link to v2 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 05692ff..a478dba 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A [quadtree](https://en.wikipedia.org/wiki/Quadtree) recursively partitions two- ## Installing -If you use NPM, `npm install d3-quadtree`. Otherwise, download the [latest release](https://github.com/d3/d3-quadtree/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-quadtree.v1.min.js) or as part of [D3](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported: +If you use NPM, `npm install d3-quadtree`. Otherwise, download the [latest release](https://github.com/d3/d3-quadtree/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-quadtree.v2.min.js) or as part of [D3](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported: ```html From 5f83d1f0861cd32b859134c00de2baf43e856387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Rivi=C3=A8re?= Date: Mon, 27 Jul 2020 11:07:36 +0200 Subject: [PATCH 5/5] v2.0.0-rc.1 --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 3fd9691..f1616f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,9 @@ { "name": "d3-quadtree", - "version": "1.0.7", + "version": "2.0.0-rc.1", + "publishConfig": { + "tag": "next" + }, "description": "Two-dimensional recursive spatial subdivision.", "keywords": [ "d3",