Skip to content

Commit 36fd534

Browse files
committed
Merge branch 'case-insensitive-color-names' of https://github.com/wilg/d3 into 3.5.4
2 parents 4b6bd05 + 82a0f01 commit 36fd534

7 files changed

Lines changed: 20 additions & 4 deletions

File tree

d3.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,9 @@
17121712
}
17131713
}
17141714
}
1715-
if (color = d3_rgb_names.get(format)) return rgb(color.r, color.g, color.b);
1715+
if (color = d3_rgb_names.get(format.toLowerCase())) {
1716+
return rgb(color.r, color.g, color.b);
1717+
}
17161718
if (format != null && format.charAt(0) === "#" && !isNaN(color = parseInt(format.slice(1), 16))) {
17171719
if (format.length === 4) {
17181720
r = (color & 3840) >> 4;

d3.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/color/rgb.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ function d3_rgb_parse(format, rgb, hsl) {
8686
}
8787

8888
/* Named colors. */
89-
if (color = d3_rgb_names.get(format)) return rgb(color.r, color.g, color.b);
89+
if (color = d3_rgb_names.get(format.toLowerCase())) {
90+
return rgb(color.r, color.g, color.b);
91+
}
9092

9193
/* Hexadecimal colors: #rgb and #rrggbb. */
9294
if (format != null && format.charAt(0) === "#" && !isNaN(color = parseInt(format.slice(1), 16))) {

test/color/hcl-test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ suite.addBatch({
4141
"parses color names (e.g., \"moccasin\")": function(d3) {
4242
assert.hclEqual(d3.hcl("moccasin"), 84.71288921124494, 26.472460854104156, 91.72317744746022);
4343
},
44+
"parses color names (e.g., \"Moccasin\")": function(d3) {
45+
assert.hclEqual(d3.hcl("moccasin"), 84.71288921124494, 26.472460854104156, 91.72317744746022);
46+
},
4447
"parses and converts RGB format (e.g., \"rgb(102, 102, 0)\")": function(d3) {
4548
assert.hclEqual(d3.hcl("rgb(102, 102, 0)"), 102.85124420310271, 49.44871600399321, 41.73251953866431);
4649
},

test/color/hsl-test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ suite.addBatch({
4040
assert.hslEqual(d3.hsl("moccasin"), 38.108108, 1, .854902);
4141
assert.hslEqual(d3.hsl("aliceblue"), 208, 1, .970588);
4242
assert.hslEqual(d3.hsl("yellow"), 60, 1, .5);
43+
assert.hslEqual(d3.hsl("Moccasin"), 38.108108, 1, .854902);
44+
assert.hslEqual(d3.hsl("Aliceblue"), 208, 1, .970588);
45+
assert.hslEqual(d3.hsl("Yellow"), 60, 1, .5);
4346
},
4447
"parses and converts RGB format (e.g., \"rgb(102, 102, 0)\")": function(d3) {
4548
assert.hslEqual(d3.hsl("rgb(102, 102, 0)"), 60, 1, .2);

test/color/lab-test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ suite.addBatch({
4141
"parses color names (e.g., \"moccasin\")": function(d3) {
4242
assert.labEqual(d3.lab("moccasin"), 91.72317744746022, 2.4393469358685027, 26.359832514614844);
4343
},
44+
"parses color names (e.g., \"Moccasin\")": function(d3) {
45+
assert.labEqual(d3.lab("Moccasin"), 91.72317744746022, 2.4393469358685027, 26.359832514614844);
46+
},
4447
"parses and converts RGB format (e.g., \"rgb(102, 102, 0)\")": function(d3) {
4548
assert.labEqual(d3.lab("rgb(102, 102, 0)"), 41.73251953866431, -10.998411255098816, 48.21006600604577);
4649
},

test/color/rgb-test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ suite.addBatch({
5151
assert.rgbEqual(d3.rgb("moccasin"), 255, 228, 181);
5252
assert.rgbEqual(d3.rgb("aliceblue"), 240, 248, 255);
5353
assert.rgbEqual(d3.rgb("yellow"), 255, 255, 0);
54+
assert.rgbEqual(d3.rgb("Moccasin"), 255, 228, 181);
55+
assert.rgbEqual(d3.rgb("Aliceblue"), 240, 248, 255);
56+
assert.rgbEqual(d3.rgb("Yellow"), 255, 255, 0);
5457
},
5558
"parses \"rebeccapurple\"": function(d3) {
5659
assert.rgbEqual(d3.rgb("rebeccapurple"), 102, 51, 153);

0 commit comments

Comments
 (0)