Skip to content

Commit 8517693

Browse files
authored
Merge pull request #1 from visjs/master
Merge master to fork
2 parents 2b21340 + 066b3a7 commit 8517693

File tree

4 files changed

+1702
-32
lines changed

4 files changed

+1702
-32
lines changed

lib/network/modules/components/Edge.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,15 @@ class Edge {
202202

203203
// handle multiple input cases for color
204204
if (newOptions.color !== undefined && newOptions.color !== null) {
205-
let fromColor = newOptions.color;
205+
const fromColor = util.isString(newOptions.color)
206+
? {
207+
color: newOptions.color,
208+
highlight: newOptions.color,
209+
hover: newOptions.color,
210+
inherit: false,
211+
opacity: 1
212+
}
213+
: newOptions.color;
206214
let toColor = parentOptions.color;
207215

208216
// If passed, fill in values from default options - required in the case of no prototype bridging

test/edge-color.test.ts

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { expect } from "chai";
2+
3+
import Edge from "../lib/network/modules/components/Edge";
4+
5+
describe("Edge color", function(): void {
6+
const setOptions = Edge.prototype.setOptions;
7+
8+
describe("parse options", function(): void {
9+
it("object", function(): void {
10+
const parentOptions = {
11+
color: {
12+
color: "#012345",
13+
highlight: "#012345",
14+
hover: "#012345",
15+
inherit: false,
16+
opacity: 1
17+
}
18+
};
19+
const newOptions = {
20+
color: {
21+
color: "#543210",
22+
highlight: "#654321",
23+
hover: "#765432",
24+
inherit: false,
25+
opacity: 1
26+
}
27+
};
28+
const allowDeletion = false;
29+
const globalOptions = {};
30+
const copyFromGlobals = false;
31+
32+
Edge.parseOptions(
33+
parentOptions,
34+
newOptions,
35+
allowDeletion,
36+
globalOptions,
37+
copyFromGlobals
38+
);
39+
40+
expect(parentOptions)
41+
.to.have.ownProperty("color")
42+
.that.deep.equals({
43+
color: "#543210",
44+
highlight: "#654321",
45+
hover: "#765432",
46+
inherit: false,
47+
opacity: 1
48+
});
49+
});
50+
51+
it("string", function(): void {
52+
const parentOptions = {
53+
color: {
54+
color: "#012345",
55+
highlight: "#123456",
56+
hover: "#234567",
57+
inherit: false,
58+
opacity: 1
59+
}
60+
};
61+
const newOptions = { color: "#543210" };
62+
const allowDeletion = false;
63+
const globalOptions = {};
64+
const copyFromGlobals = false;
65+
66+
Edge.parseOptions(
67+
parentOptions,
68+
newOptions,
69+
allowDeletion,
70+
globalOptions,
71+
copyFromGlobals
72+
);
73+
74+
expect(parentOptions)
75+
.to.have.ownProperty("color")
76+
.that.deep.equals({
77+
color: "#543210",
78+
highlight: "#543210",
79+
hover: "#543210",
80+
inherit: false,
81+
opacity: 1
82+
});
83+
});
84+
});
85+
});

0 commit comments

Comments
 (0)