Skip to content

Commit 4b839b6

Browse files
committed
More restrictive copy constructor.
Rather than duck-checking for a forEach method, limit the use of forEach to d3_Map instances. In ECMAScript 6, the map.forEach method passes the callback (value, key) rather than (key, value); likewise, array.forEach does the same.
1 parent c14858b commit 4b839b6

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

d3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ d3 = function() {
204204
}
205205
d3.map = function(object) {
206206
var map = new d3_Map();
207-
if (object && object.forEach) object.forEach(function(key, value) {
207+
if (object instanceof d3_Map) object.forEach(function(key, value) {
208208
map.set(key, value);
209209
}); else for (var key in object) map.set(key, object[key]);
210210
return map;

0 commit comments

Comments
 (0)