Skip to content

Commit b085292

Browse files
committed
Add type coercion for d3.geo.path.pointRadius.
1 parent 623b594 commit b085292

4 files changed

Lines changed: 7 additions & 3 deletions

File tree

d3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6269,7 +6269,7 @@
62696269
};
62706270
path.pointRadius = function(_) {
62716271
if (!arguments.length) return pointRadius;
6272-
pointRadius = _;
6272+
pointRadius = typeof _ === "function" ? _ : +_;
62736273
return path;
62746274
};
62756275
return path;

d3.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/geo/path.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ d3.geo.path = function() {
4949

5050
path.pointRadius = function(_) {
5151
if (!arguments.length) return pointRadius;
52-
pointRadius = _;
52+
pointRadius = typeof _ === "function" ? _ : +_;
5353
return path;
5454
};
5555

test/geo/path-test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ suite.addBatch({
122122
var path = d3.geo.path(), radius = function() { return 5; };
123123
assert.strictEqual(path.pointRadius(), 4.5);
124124
assert.strictEqual(path.pointRadius(radius).pointRadius(), radius);
125+
},
126+
"coerces a constant point radius to a number": function() {
127+
var path = d3.geo.path();
128+
assert.strictEqual(path.pointRadius("5").pointRadius(), 5);
125129
}
126130
},
127131

0 commit comments

Comments
 (0)