Skip to content

Commit 98adfae

Browse files
committed
IE9 fixes
1 parent 515e6d9 commit 98adfae

File tree

5 files changed

+31
-13
lines changed

5 files changed

+31
-13
lines changed

src/components/drawing/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ drawing.lineGroupStyle = function(s, lw, lc, ld) {
112112
};
113113

114114
drawing.dashLine = function(s, dash, lineWidth) {
115+
lineWidth = lineWidth || 0;
115116
var dlw = Math.max(lineWidth, 3);
116117

117118
if(dash === 'solid') dash = '';

src/components/modebar/modebar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ proto.createButton = function(config) {
147147
}
148148

149149
button.setAttribute('data-toggle', config.toggle || false);
150-
if(config.toggle) button.classList.add('active');
150+
if(config.toggle) d3.select(button).classed('active', true);
151151

152152
button.appendChild(this.createIcon(config.icon || Icons.question));
153153
button.setAttribute('data-gravity', config.gravity || 'n');

src/lib/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,14 @@ lib.isIE = function() {
556556
return typeof window.navigator.msSaveBlob !== 'undefined';
557557
};
558558

559+
/**
560+
* Duck typing to recognize a d3 selection, mostly for IE9's benefit
561+
* because it doesn't handle instanceof like modern browsers
562+
*/
563+
lib.isD3Selection = function(obj) {
564+
return obj && (typeof obj.classed === 'function');
565+
};
566+
559567

560568
/**
561569
* Converts a string path to an object.

src/lib/loggers.js

+18-11
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ loggers.log = function() {
2828
messages.push(arguments[i]);
2929
}
3030

31-
if(console.trace) {
32-
console.trace.apply(console, messages);
33-
} else {
34-
console.log.apply(console, messages);
35-
}
31+
apply(console.trace || console.log, messages);
3632
}
3733
};
3834

@@ -44,11 +40,7 @@ loggers.warn = function() {
4440
messages.push(arguments[i]);
4541
}
4642

47-
if(console.trace) {
48-
console.trace.apply(console, messages);
49-
} else {
50-
console.log.apply(console, messages);
51-
}
43+
apply(console.trace || console.log, messages);
5244
}
5345
};
5446

@@ -60,6 +52,21 @@ loggers.error = function() {
6052
messages.push(arguments[i]);
6153
}
6254

63-
console.error.apply(console, arguments);
55+
apply(console.error, messages);
6456
}
6557
};
58+
59+
/*
60+
* Robust apply, for IE9 where console.log doesn't support
61+
* apply like other functions do
62+
*/
63+
function apply(f, args) {
64+
if(f.apply) {
65+
f.apply(f, args);
66+
}
67+
else {
68+
for(var i = 0; i < args.length; i++) {
69+
f(args[i]);
70+
}
71+
}
72+
}

src/plots/cartesian/graph_interact.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,9 @@ fx.loneHover = function(hoverItem, opts) {
792792
};
793793

794794
fx.loneUnhover = function(containerOrSelection) {
795-
var selection = containerOrSelection instanceof d3.selection ?
795+
// duck type whether the arg is a d3 selection because ie9 doesn't
796+
// handle instanceof like modern browsers do.
797+
var selection = Lib.isD3Selection(containerOrSelection) ?
796798
containerOrSelection :
797799
d3.select(containerOrSelection);
798800

0 commit comments

Comments
 (0)