Skip to content

Commit f502d3d

Browse files
authored
Merge pull request #5380 from plotly/cleanup-IE9-IE10-fallbacks
Cleanup unused IE9 and IE10 fallbacks
2 parents c7e5a22 + db453ef commit f502d3d

File tree

10 files changed

+20
-179
lines changed

10 files changed

+20
-179
lines changed

src/lib/array.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,8 @@
1010

1111
var isArray = Array.isArray;
1212

13-
// IE9 fallbacks
14-
15-
var ab = (typeof ArrayBuffer === 'undefined' || !ArrayBuffer.isView) ?
16-
{isView: function() { return false; }} :
17-
ArrayBuffer;
18-
19-
var dv = (typeof DataView === 'undefined') ?
20-
function() {} :
21-
DataView;
13+
var ab = ArrayBuffer;
14+
var dv = DataView;
2215

2316
function isTypedArray(a) {
2417
return ab.isView(a) && !(a instanceof dv);

src/lib/index.js

+1-10
Original file line numberDiff line numberDiff line change
@@ -712,11 +712,6 @@ lib.isIE = function() {
712712
return typeof window.navigator.msSaveBlob !== 'undefined';
713713
};
714714

715-
var IS_IE9_OR_BELOW_REGEX = /MSIE [1-9]\./;
716-
lib.isIE9orBelow = function() {
717-
return lib.isIE() && IS_IE9_OR_BELOW_REGEX.test(window.navigator.userAgent);
718-
};
719-
720715
var IS_SAFARI_REGEX = /Version\/[\d\.]+.*Safari/;
721716
lib.isSafari = function() {
722717
return IS_SAFARI_REGEX.test(window.navigator.userAgent);
@@ -727,12 +722,8 @@ lib.isIOS = function() {
727722
return IS_IOS_REGEX.test(window.navigator.userAgent);
728723
};
729724

730-
/**
731-
* Duck typing to recognize a d3 selection, mostly for IE9's benefit
732-
* because it doesn't handle instanceof like modern browsers
733-
*/
734725
lib.isD3Selection = function(obj) {
735-
return obj && (typeof obj.classed === 'function');
726+
return obj instanceof d3.selection;
736727
};
737728

738729
/**

src/lib/loggers.js

+3-28
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ loggers.log = function() {
3030
for(i = 0; i < arguments.length; i++) {
3131
messages.push(arguments[i]);
3232
}
33-
apply(console.trace || console.log, messages);
33+
console.trace.apply(console, messages);
3434
}
3535

3636
if(dfltConfig.notifyOnLogging > 1) {
@@ -50,7 +50,7 @@ loggers.warn = function() {
5050
for(i = 0; i < arguments.length; i++) {
5151
messages.push(arguments[i]);
5252
}
53-
apply(console.trace || console.log, messages);
53+
console.trace.apply(console, messages);
5454
}
5555

5656
if(dfltConfig.notifyOnLogging > 0) {
@@ -70,7 +70,7 @@ loggers.error = function() {
7070
for(i = 0; i < arguments.length; i++) {
7171
messages.push(arguments[i]);
7272
}
73-
apply(console.error, messages);
73+
console.error.apply(console, messages);
7474
}
7575

7676
if(dfltConfig.notifyOnLogging > 0) {
@@ -81,28 +81,3 @@ loggers.error = function() {
8181
notifier(lines.join('<br>'), 'stick');
8282
}
8383
};
84-
85-
/*
86-
* Robust apply, for IE9 where console.log doesn't support
87-
* apply like other functions do
88-
*/
89-
function apply(f, args) {
90-
if(f && f.apply) {
91-
try {
92-
// `this` should always be console, since here we're always
93-
// applying a method of the console object.
94-
f.apply(console, args);
95-
return;
96-
} catch(e) { /* in case apply failed, fall back on the code below */ }
97-
}
98-
99-
// no apply - just try calling the function on each arg independently
100-
for(var i = 0; i < args.length; i++) {
101-
try {
102-
f(args[i]);
103-
} catch(e) {
104-
// still fails - last resort simple console.log
105-
console.log(args[i]);
106-
}
107-
}
108-
}

src/snapshot/filesaver.js

-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ function fileSaver(url, name, format) {
3131
var blob;
3232
var objectUrl;
3333

34-
if(Lib.isIE9orBelow()) {
35-
reject(new Error('IE < 10 unsupported'));
36-
}
37-
3834
// Safari doesn't allow downloading of blob urls
3935
if(Lib.isSafari()) {
4036
var prefix = format === 'svg' ? ',' : ';base64,';

src/snapshot/svgtoimg.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function svgToImg(opts) {
4545
var img = new Image();
4646
var svgBlob, url;
4747

48-
if(format === 'svg' || Lib.isIE9orBelow() || Lib.isSafari()) {
48+
if(format === 'svg' || Lib.isSafari()) {
4949
url = helpers.encodeSVG(svg);
5050
} else {
5151
svgBlob = helpers.createBlob(svg, 'svg');

src/snapshot/tosvg.js

+2
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ module.exports = function toSVG(gd, format, scale) {
164164
// Fix quotations around font strings and gradient URLs
165165
s = s.replace(DUMMY_REGEX, '\'');
166166

167+
// Do we need this process now that IE9 and IE10 are not supported?
168+
167169
// IE is very strict, so we will need to clean
168170
// svg with the following regex
169171
// yes this is messy, but do not know a better way

test/image/strict-d3.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* strict-d3: wrap selection.style to prohibit specific incorrect style values
33
* that are known to cause problems in IE (at least IE9)
44
*/
5+
56
'use strict';
67

78
var d3 = require('@plotly/d3');

test/jasmine/bundle_tests/ie9_test.js

-42
This file was deleted.

test/jasmine/karma.conf.js

-11
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ if(argv.info) {
4848
'Run all tests with the `noCI` tag on Firefox in a 1500px wide window:',
4949
' $ npm run test-jasmine -- --tags=noCI --FF --width=1500',
5050
'',
51-
'Run the `ie9_test.js` bundle test with the verbose reporter:',
52-
' $ npm run test-jasmine -- --bundleTest=ie9 --verbose',
53-
'',
5451
'Arguments:',
5552
' - All non-flagged arguments corresponds to the test suites in `test/jasmine/tests/` to be run.',
5653
' No need to add the `_test.js` suffix, we expand them correctly here.',
@@ -122,7 +119,6 @@ if(isFullSuite) {
122119
var pathToShortcutPath = path.join(__dirname, '..', '..', 'tasks', 'util', 'shortcut_paths.js');
123120
var pathToStrictD3 = path.join(__dirname, '..', '..', 'tasks', 'util', 'strict_d3.js');
124121
var pathToJQuery = path.join(__dirname, 'assets', 'jquery-1.8.3.min.js');
125-
var pathToIE9mock = path.join(__dirname, 'assets', 'ie9_mock.js');
126122
var pathToCustomMatchers = path.join(__dirname, 'assets', 'custom_matchers.js');
127123
var pathToUnpolyfill = path.join(__dirname, 'assets', 'unpolyfill.js');
128124
var pathToMathJax = path.join(constants.pathToDist, 'extras', 'mathjax');
@@ -323,13 +319,6 @@ if(isBundleTest) {
323319
func.defaultConfig.files.push(constants.pathToPlotlyDistMin);
324320
func.defaultConfig.preprocessors[testFileGlob] = ['browserify'];
325321
break;
326-
case 'ie9':
327-
// load ie9_mock.js before plotly.js+test bundle
328-
// to catch reference errors that could occur
329-
// when plotly.js is first loaded.
330-
func.defaultConfig.files.push(pathToIE9mock);
331-
func.defaultConfig.preprocessors[testFileGlob] = ['browserify'];
332-
break;
333322
case 'plotschema':
334323
func.defaultConfig.browserify.ignoreTransform = './tasks/compress_attributes.js';
335324
func.defaultConfig.preprocessors[testFileGlob] = ['browserify'];

test/jasmine/tests/lib_test.js

+10-74
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) {
@@ -1675,28 +1672,25 @@ describe('Test lib.js:', function() {
16751672
var stashLogLevel;
16761673
var stashOnGraphLogLevel;
16771674

1678-
function consoleFn(name, hasApply, messages) {
1675+
function consoleFn(name, messages) {
16791676
var out = function() {
1680-
if(hasApply) expect(this).toBe(window.console);
16811677
var args = [];
16821678
for(var i = 0; i < arguments.length; i++) args.push(arguments[i]);
16831679
messages.push([name, args]);
16841680
};
16851681

1686-
if(!hasApply) out.apply = undefined;
1687-
16881682
return out;
16891683
}
16901684

1691-
function mockConsole(hasApply, hasTrace, hasError) {
1685+
function mockConsole() {
16921686
var out = {
16931687
MESSAGES: []
16941688
};
1695-
out.log = consoleFn('log', hasApply, out.MESSAGES);
1689+
out.log = consoleFn('log', out.MESSAGES);
16961690

1697-
if(hasError) out.error = consoleFn('error', hasApply, out.MESSAGES);
1691+
out.error = consoleFn('error', out.MESSAGES);
16981692

1699-
if(hasTrace) out.trace = consoleFn('trace', hasApply, out.MESSAGES);
1693+
out.trace = consoleFn('trace', out.MESSAGES);
17001694

17011695
return out;
17021696
}
@@ -1713,8 +1707,8 @@ describe('Test lib.js:', function() {
17131707
config.notifyOnLogging = stashOnGraphLogLevel;
17141708
});
17151709

1716-
it('emits one console message if apply is available', function() {
1717-
var c = window.console = mockConsole(true, true, true);
1710+
it('emits one console message', function() {
1711+
var c = window.console = mockConsole();
17181712
config.logging = 2;
17191713

17201714
Lib.log('tick', 'tock', 'tick', 'tock', 1);
@@ -1728,50 +1722,8 @@ describe('Test lib.js:', function() {
17281722
]);
17291723
});
17301724

1731-
it('falls back on console.log if no trace', function() {
1732-
var c = window.console = mockConsole(true, false, true);
1733-
config.logging = 2;
1734-
1735-
Lib.log('Hi');
1736-
Lib.warn(42);
1737-
1738-
expect(c.MESSAGES).toEqual([
1739-
['log', ['LOG:', 'Hi']],
1740-
['log', ['WARN:', 42]]
1741-
]);
1742-
});
1743-
1744-
it('falls back on separate calls if no apply', function() {
1745-
var c = window.console = mockConsole(false, false, true);
1746-
config.logging = 2;
1747-
1748-
Lib.log('tick', 'tock', 'tick', 'tock', 1);
1749-
Lib.warn('I\'m', 'a', 'little', 'cuckoo', 'clock', [1, 2]);
1750-
Lib.error('cuckoo!', 'cuckoo!!!', {a: 1, b: 2});
1751-
1752-
expect(c.MESSAGES).toEqual([
1753-
['log', ['LOG:']],
1754-
['log', ['tick']],
1755-
['log', ['tock']],
1756-
['log', ['tick']],
1757-
['log', ['tock']],
1758-
['log', [1]],
1759-
['log', ['WARN:']],
1760-
['log', ['I\'m']],
1761-
['log', ['a']],
1762-
['log', ['little']],
1763-
['log', ['cuckoo']],
1764-
['log', ['clock']],
1765-
['log', [[1, 2]]],
1766-
['error', ['ERROR:']],
1767-
['error', ['cuckoo!']],
1768-
['error', ['cuckoo!!!']],
1769-
['error', [{a: 1, b: 2}]]
1770-
]);
1771-
});
1772-
17731725
it('omits .log at log level 1', function() {
1774-
var c = window.console = mockConsole(true, true, true);
1726+
var c = window.console = mockConsole();
17751727
config.logging = 1;
17761728

17771729
Lib.log(1);
@@ -1785,7 +1737,7 @@ describe('Test lib.js:', function() {
17851737
});
17861738

17871739
it('logs nothing at log level 0', function() {
1788-
var c = window.console = mockConsole(true, true, true);
1740+
var c = window.console = mockConsole();
17891741
config.logging = 0;
17901742

17911743
Lib.log(1);
@@ -1795,22 +1747,6 @@ describe('Test lib.js:', function() {
17951747
expect(c.MESSAGES).toEqual([]);
17961748
});
17971749

1798-
it('falls back on simple log if there is no console.error', function() {
1799-
// TODO
1800-
1801-
var c = window.console = mockConsole(true, true, false);
1802-
config.logging = 2;
1803-
1804-
Lib.error('who are you', 'who who... are you', {a: 1, b: 2});
1805-
1806-
expect(c.MESSAGES).toEqual([
1807-
['log', ['ERROR:']],
1808-
['log', ['who are you']],
1809-
['log', ['who who... are you']],
1810-
['log', [{a: 1, b: 2}]]
1811-
]);
1812-
});
1813-
18141750
describe('should log message in notifier div in accordance notifyOnLogging config option', function() {
18151751
var query = '.notifier-note';
18161752

0 commit comments

Comments
 (0)