@yanqirenshi/d3.deployment 0.5.1 → 0.5.2
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 -1
- package/package.json +1 -1
- package/tests/Rectum.test.js +23 -0
|
@@ -58,7 +58,11 @@ var Edge = exports["default"] = /*#__PURE__*/function () {
|
|
|
58
58
|
value: function normalize(data) {
|
|
59
59
|
var new_data = this.dataTemplate();
|
|
60
60
|
new_data._core = data;
|
|
61
|
-
|
|
61
|
+
|
|
62
|
+
// 入力に id があればそれを、無ければ Rectum.makeEdges が採番した _id を引き継ぐ。
|
|
63
|
+
// (これを落とすと _id=null → data-edge-id="null" になり、
|
|
64
|
+
// ドラッグ時の redraw が対象 path を特定できず接続線が追従しない)
|
|
65
|
+
if (data.id || data.id === 0) new_data._id = data.id;else if (data._id || data._id === 0) new_data._id = data._id;
|
|
62
66
|
if (data.from.id) new_data.from.id = data.from.id;
|
|
63
67
|
if (data.to.id) new_data.to.id = data.to.id;
|
|
64
68
|
if (data.stroke) {
|
package/package.json
CHANGED
package/tests/Rectum.test.js
CHANGED
|
@@ -53,6 +53,29 @@ const buildData = () => {
|
|
|
53
53
|
return { rectum, data: rectum.data() };
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
+
test('edges without an explicit id inherit the auto-numbered _id (drag redraw needs it)', () => {
|
|
57
|
+
const rectum = new Rectum({});
|
|
58
|
+
|
|
59
|
+
// 入力エッジに id を与えない → makeEdges が _id を採番、normalize が引き継ぐべき。
|
|
60
|
+
rectum.data({
|
|
61
|
+
nodes: [
|
|
62
|
+
{ type: 'NODE', id: 1, label: { text: 'A' }, size: { w: 100, h: 100 }, position: { x: 0, y: 0 } },
|
|
63
|
+
{ type: 'NODE', id: 2, label: { text: 'B' }, size: { w: 100, h: 100 }, position: { x: 300, y: 0 } },
|
|
64
|
+
],
|
|
65
|
+
edges: [
|
|
66
|
+
{ from: { id: 1, position: 0 }, to: { id: 2, position: 180 }, port: 45 },
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const edges = rectum.data().edges.list;
|
|
71
|
+
|
|
72
|
+
expect(edges).toHaveLength(1);
|
|
73
|
+
// _id が null のままだと data-edge-id="null" になり redraw が対象を見つけられない。
|
|
74
|
+
expect(edges[0]._id).not.toBeNull();
|
|
75
|
+
expect(edges[0]._id).not.toBeUndefined();
|
|
76
|
+
expect(typeof edges[0]._id).toBe('number');
|
|
77
|
+
});
|
|
78
|
+
|
|
56
79
|
test('collectSubtree gathers a node and all descendants', () => {
|
|
57
80
|
const { rectum, data } = buildData();
|
|
58
81
|
|