Skip to content

Commit 42c97e2

Browse files
committed
drop duck typing to recognize a d3 selection
1 parent 9276d08 commit 42c97e2

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

src/lib/index.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -722,14 +722,8 @@ lib.isIOS = function() {
722722
return IS_IOS_REGEX.test(window.navigator.userAgent);
723723
};
724724

725-
// Do we need this process now that IE9 and IE10 are not supported?
726-
727-
/**
728-
* Duck typing to recognize a d3 selection, mostly for IE9's benefit
729-
* because it doesn't handle instanceof like modern browsers
730-
*/
731725
lib.isD3Selection = function(obj) {
732-
return obj && (typeof obj.classed === 'function');
726+
return obj instanceof d3.selection;
733727
};
734728

735729
/**

test/jasmine/tests/lib_test.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -1643,10 +1643,7 @@ describe('Test lib.js:', function() {
16431643
// this is what got us into trouble actually - d3 selections can
16441644
// contain non-nodes - say for example d3 selections! then they
16451645
// don't work correctly. But it makes a convenient test!
1646-
d3.select(1),
1647-
// just showing what we actually do in this function: duck type
1648-
// using the `classed` method.
1649-
{classed: function(v) { return !!v; }}
1646+
d3.select(1)
16501647
];
16511648

16521649
yesSelections.forEach(function(v) {

0 commit comments

Comments
 (0)