@yanqirenshi/d3.deployment 0.8.4 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js/datamodels/Edge.js +5 -2
- package/package.json +1 -1
- package/tests/Rectum.test.js +35 -0
|
@@ -63,8 +63,11 @@ var Edge = exports["default"] = /*#__PURE__*/function () {
|
|
|
63
63
|
// (これを落とすと _id=null → data-edge-id="null" になり、
|
|
64
64
|
// ドラッグ時の redraw が対象 path を特定できず接続線が追従しない)
|
|
65
65
|
if (data.id || data.id === 0) new_data._id = data.id;else if (data._id || data._id === 0) new_data._id = data._id;
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
|
|
67
|
+
// id: 0 も有効な参照として扱う(truthy チェックだと 0 のノードへの
|
|
68
|
+
// 接続が無視され、ポート解決時にクラッシュする — sitemap 側 issue #11 と同族)
|
|
69
|
+
if (data.from.id !== undefined && data.from.id !== null) new_data.from.id = data.from.id;
|
|
70
|
+
if (data.to.id !== undefined && data.to.id !== null) new_data.to.id = data.to.id;
|
|
68
71
|
if (data.stroke) {
|
|
69
72
|
if (data.stroke.color) new_data.stroke.color = data.stroke.color;
|
|
70
73
|
if (data.stroke.width) new_data.stroke.width = data.stroke.width;
|
package/package.json
CHANGED
package/tests/Rectum.test.js
CHANGED
|
@@ -147,3 +147,38 @@ test('moving a child leaf shifts only that child, and edges from it follow', ()
|
|
|
147
147
|
expect(child._position).toEqual({ ...c0, x: c0.x - 20, y: c0.y + 40 });
|
|
148
148
|
expect(parent._position).toEqual(p0); // 親は動かない
|
|
149
149
|
});
|
|
150
|
+
|
|
151
|
+
// sitemap 側 issue #11 と同族: id 0 のノードをエッジの from/to に指定すると
|
|
152
|
+
// Edge.normalize の truthy チェックで参照が落ち、ポート解決でクラッシュしていた。
|
|
153
|
+
test('id 0 is a valid node reference in edges (same class as sitemap issue #11)', () => {
|
|
154
|
+
const rectum = new Rectum({});
|
|
155
|
+
const sample = {
|
|
156
|
+
nodes: [
|
|
157
|
+
{
|
|
158
|
+
type: 'NODE', id: 0,
|
|
159
|
+
label: { text: 'Zero', position: { x: 20, y: 20 } },
|
|
160
|
+
size: { w: 200, h: 100 }, position: { x: 0, y: 0 },
|
|
161
|
+
children: [],
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
type: 'NODE', id: 1,
|
|
165
|
+
label: { text: 'One', position: { x: 20, y: 20 } },
|
|
166
|
+
size: { w: 200, h: 100 }, position: { x: 400, y: 0 },
|
|
167
|
+
children: [],
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
edges: [
|
|
171
|
+
{ id: 100, from: { id: 0, position: 0 }, to: { id: 1, position: 180 } },
|
|
172
|
+
],
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
expect(() => rectum.data(sample)).not.toThrow();
|
|
176
|
+
|
|
177
|
+
const data = rectum.data();
|
|
178
|
+
const edge = data.edges.list.find((e) => e._id === 100);
|
|
179
|
+
|
|
180
|
+
expect(edge.from.id).toBe(0);
|
|
181
|
+
expect(edge.from.node).toBe(data.nodes.ht[0]);
|
|
182
|
+
expect(typeof edge.from.position.x).toBe('number');
|
|
183
|
+
expect(typeof edge.from.position.y).toBe('number');
|
|
184
|
+
});
|