From daa339b9ec853c1a469311d5132869977cb9c322 Mon Sep 17 00:00:00 2001 From: Curran Kelleher <68416+curran@users.noreply.github.com> Date: Mon, 24 May 2021 13:09:37 -0400 Subject: [PATCH 1/4] Implement selection.merge(transition) Closes #257 --- src/selection/merge.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/selection/merge.js b/src/selection/merge.js index eac9604..084af5c 100644 --- a/src/selection/merge.js +++ b/src/selection/merge.js @@ -1,7 +1,8 @@ import {Selection} from "./index.js"; -export default function(selection) { - if (!(selection instanceof Selection)) throw new Error("invalid merge"); +export default function(context) { + if (!(selection instanceof Selection) && !context.selection) throw new Error("invalid merge"); + var selection = context.selection ? context.selection() : context; for (var groups0 = this._groups, groups1 = selection._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) { for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) { From 1e6edde62c90c0fc301d3ee7be4c164037bc0438 Mon Sep 17 00:00:00 2001 From: Curran Kelleher <68416+curran@users.noreply.github.com> Date: Tue, 25 May 2021 12:16:52 -0400 Subject: [PATCH 2/4] Update src/selection/merge.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Philippe Rivière --- src/selection/merge.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/selection/merge.js b/src/selection/merge.js index 084af5c..0ba4aef 100644 --- a/src/selection/merge.js +++ b/src/selection/merge.js @@ -1,8 +1,8 @@ import {Selection} from "./index.js"; export default function(context) { - if (!(selection instanceof Selection) && !context.selection) throw new Error("invalid merge"); var selection = context.selection ? context.selection() : context; + if (!(selection instanceof Selection)) throw new Error("invalid merge"); for (var groups0 = this._groups, groups1 = selection._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) { for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) { From 3284abe5660a27458135ec678448be1629b5fa89 Mon Sep 17 00:00:00 2001 From: Curran Kelleher <68416+curran@users.noreply.github.com> Date: Tue, 25 May 2021 13:09:29 -0400 Subject: [PATCH 3/4] Update src/selection/merge.js --- src/selection/merge.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/selection/merge.js b/src/selection/merge.js index 0ba4aef..8be1a21 100644 --- a/src/selection/merge.js +++ b/src/selection/merge.js @@ -1,7 +1,7 @@ import {Selection} from "./index.js"; export default function(context) { - var selection = context.selection ? context.selection() : context; + var selection = (context && context.selection) ? context.selection() : context; if (!(selection instanceof Selection)) throw new Error("invalid merge"); for (var groups0 = this._groups, groups1 = selection._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) { From f2ee26eb9eabd49e4bdb93dc6043558d7cd6d8a2 Mon Sep 17 00:00:00 2001 From: Curran Kelleher <68416+curran@users.noreply.github.com> Date: Tue, 25 May 2021 14:15:32 -0400 Subject: [PATCH 4/4] Update src/selection/merge.js Co-authored-by: Mike Bostock --- src/selection/merge.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/selection/merge.js b/src/selection/merge.js index 8be1a21..0ba4aef 100644 --- a/src/selection/merge.js +++ b/src/selection/merge.js @@ -1,7 +1,7 @@ import {Selection} from "./index.js"; export default function(context) { - var selection = (context && context.selection) ? context.selection() : context; + var selection = context.selection ? context.selection() : context; if (!(selection instanceof Selection)) throw new Error("invalid merge"); for (var groups0 = this._groups, groups1 = selection._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) {