Skip to content

Commit 1f36292

Browse files
authored
Merge pull request #7251 from plotly/cleanup-IE-cases
Cleanup old code that was there to support the Internet Explorer
2 parents bd56393 + 14aeddd commit 1f36292

18 files changed

+6
-215
lines changed

draftlogs/7251_change.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Cleanup remaining code that was there to support the Internet Explorer [[#7251](https://github.com/plotly/plotly.js/pull/7251)]

src/components/modebar/buttons.js

-5
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ modeBarButtons.toImage = {
5151

5252
Lib.notifier(_(gd, 'Taking snapshot - this may take a few seconds'), 'long');
5353

54-
if(opts.format !== 'svg' && Lib.isIE()) {
55-
Lib.notifier(_(gd, 'IE only supports svg. Changing format to svg.'), 'long');
56-
opts.format = 'svg';
57-
}
58-
5954
['filename', 'width', 'height', 'scale'].forEach(function(key) {
6055
if(key in toImageButtonOptions) {
6156
opts[key] = toImageButtonOptions[key];

src/css/_base.scss

-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ a {
2727
@include vendor('user-select', none);
2828
}
2929

30-
//Required for IE11. Other browsers set this by default.
31-
svg { overflow: hidden; }
32-
3330
svg a { fill: $color-brand-primary; }
3431
svg a:hover { fill: #3c6dc5; }
3532

src/lib/index.js

-4
Original file line numberDiff line numberDiff line change
@@ -755,10 +755,6 @@ lib.containsAny = function(s, fragments) {
755755
return false;
756756
};
757757

758-
lib.isIE = function() {
759-
return typeof window.navigator.msSaveBlob !== 'undefined';
760-
};
761-
762758
var IS_SAFARI_REGEX = /Version\/[\d\.]+.*Safari/;
763759
lib.isSafari = function() {
764760
return IS_SAFARI_REGEX.test(window.navigator.userAgent);

src/lib/search.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ exports.sorterDes = function(a, b) { return b - a; };
6464
*/
6565
exports.distinctVals = function(valsIn) {
6666
var vals = valsIn.slice(); // otherwise we sort the original array...
67-
vals.sort(exports.sorterAsc); // undefined listed in the end - also works on IE11
67+
vals.sort(exports.sorterAsc); // undefined listed in the end
6868

6969
var last;
7070
for(last = vals.length - 1; last > -1; last--) {

src/lib/supports_pixelated_image.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function supportsPixelatedImage() {
1919
_supportsPixelated = false;
2020

2121
// @see https://github.com/plotly/plotly.js/issues/6604
22-
var unsupportedBrowser = Lib.isIE() || Lib.isSafari() || Lib.isIOS();
22+
var unsupportedBrowser = Lib.isSafari() || Lib.isIOS();
2323

2424
if(window.navigator.userAgent && !unsupportedBrowser) {
2525
var declarations = Array.from(constants.CSS_DECLARATIONS).reverse();

src/plots/plots.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ plots.addLinks = function(gd) {
146146

147147
// If text's width is bigger than the layout
148148
// Check that text is a child node or document.body
149-
// because otherwise IE/Edge might throw an exception
149+
// because otherwise Edge might throw an exception
150150
// when calling getComputedTextLength().
151151
// Apparently offsetParent is null for invisibles.
152152
if(document.body.contains(text) && text.getComputedTextLength() >= (fullLayout.width - 20)) {

src/snapshot/download.js

-9
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,6 @@ function downloadImage(gd, opts) {
3232
reject(new Error('Snapshotting already in progress.'));
3333
}
3434

35-
// see comments within svgtoimg for additional
36-
// discussion of problems with IE
37-
// can now draw to canvas, but CORS tainted canvas
38-
// does not allow toDataURL
39-
// svg format will work though
40-
if(Lib.isIE() && opts.format !== 'svg') {
41-
reject(new Error(helpers.MSG_IE_BAD_FORMAT));
42-
}
43-
4435
if(_gd) _gd._snapshotInProgress = true;
4536
var promise = toImage(gd, opts);
4637

src/snapshot/filesaver.js

-10
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ function fileSaver(url, name, format) {
2323
var blob;
2424
var objectUrl;
2525

26-
// IE 10+ (native saveAs)
27-
if(Lib.isIE()) {
28-
// At this point we are only dealing with a decoded SVG as
29-
// a data URL (since IE only supports SVG)
30-
blob = helpers.createBlob(url, 'svg');
31-
window.navigator.msSaveBlob(blob, name);
32-
blob = null;
33-
return resolve(name);
34-
}
35-
3626
if(canUseSaveLink) {
3727
blob = helpers.createBlob(url, format);
3828
objectUrl = helpers.createObjectURL(blob);

src/snapshot/helpers.js

-2
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,3 @@ function fixBinary(b) {
6363
}
6464

6565
exports.IMAGE_URL_PREFIX = /^data:image\/\w+;base64,/;
66-
67-
exports.MSG_IE_BAD_FORMAT = 'Sorry IE does not support downloading from canvas. Try {format:\'svg\'} instead.';

src/snapshot/svgtoimg.js

-13
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,6 @@ function svgToImg(opts) {
1313
var svg = opts.svg;
1414
var format = opts.format || 'png';
1515

16-
// IE only support svg
17-
if(Lib.isIE() && format !== 'svg') {
18-
var ieSvgError = new Error(helpers.MSG_IE_BAD_FORMAT);
19-
reject(ieSvgError);
20-
// eventually remove the ev
21-
// in favor of promises
22-
if(!opts.promise) {
23-
return ev.emit('error', ieSvgError);
24-
} else {
25-
return promise;
26-
}
27-
}
28-
2916
var canvas = opts.canvas;
3017
var scale = opts.scale || 1;
3118
var w0 = opts.width || 300;

src/snapshot/tosvg.js

-26
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,6 @@ module.exports = function toSVG(gd, format, scale) {
143143
.attr('stroke-width', 0);
144144
}
145145

146-
// fix for IE namespacing quirk?
147-
// http://stackoverflow.com/questions/19610089/unwanted-namespaces-on-svg-markup-when-using-xmlserializer-in-javascript-with-ie
148-
svg.node().setAttributeNS(xmlnsNamespaces.xmlns, 'xmlns', xmlnsNamespaces.svg);
149-
svg.node().setAttributeNS(xmlnsNamespaces.xmlns, 'xmlns:xlink', xmlnsNamespaces.xlink);
150-
151146
if(format === 'svg' && scale) {
152147
svg.attr('width', scale * width);
153148
svg.attr('height', scale * height);
@@ -161,26 +156,5 @@ module.exports = function toSVG(gd, format, scale) {
161156
// Fix quotations around font strings and gradient URLs
162157
s = s.replace(DUMMY_REGEX, '\'');
163158

164-
// Do we need this process now that IE9 and IE10 are not supported?
165-
166-
// IE is very strict, so we will need to clean
167-
// svg with the following regex
168-
// yes this is messy, but do not know a better way
169-
// Even with this IE will not work due to tainted canvas
170-
// see https://github.com/kangax/fabric.js/issues/1957
171-
// http://stackoverflow.com/questions/18112047/canvas-todataurl-working-in-all-browsers-except-ie10
172-
// Leave here just in case the CORS/tainted IE issue gets resolved
173-
if(Lib.isIE()) {
174-
// replace double quote with single quote
175-
s = s.replace(/"/gi, '\'');
176-
// url in svg are single quoted
177-
// since we changed double to single
178-
// we'll need to change these to double-quoted
179-
s = s.replace(/(\('#)([^']*)('\))/gi, '(\"#$2\")');
180-
// font names with spaces will be escaped single-quoted
181-
// we'll need to change these to double-quoted
182-
s = s.replace(/(\\')/gi, '\"');
183-
}
184-
185159
return s;
186160
};

tasks/test_syntax.js

+1-31
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,13 @@ function assertJasmineSuites() {
9090

9191
/*
9292
* tests about the contents of source (and lib) files:
93-
* - check that we don't have any features that break in IE
9493
* - check that we don't use getComputedStyle unexpectedly
9594
* - check that require statements use lowercase (to match assertFileNames)
9695
* or match the case of the source file
9796
*/
9897
function assertSrcContents() {
9998
var logs = [];
10099

101-
// These are forbidden in IE *only in SVG* but since
102-
// that's 99% of what we do here, we'll forbid them entirely
103-
// until there's some HTML use case where we need them.
104-
// (not sure what we'd do then, but we'd think of something!)
105-
var IE_SVG_BLACK_LIST = ['innerHTML', 'parentElement', 'children'];
106-
107-
// Forbidden in IE in any context
108-
var IE_BLACK_LIST = ['classList'];
109-
110100
// require'd built-in modules
111101
var BUILTINS = ['events'];
112102

@@ -122,28 +112,8 @@ function assertSrcContents() {
122112
// look for .classList
123113
if(node.type === 'MemberExpression') {
124114
var source = node.source();
125-
var parts = source.split('.');
126-
var lastPart = parts[parts.length - 1];
127-
128-
if(source === 'Math.sign') {
129-
logs.push(file + ' : contains Math.sign (IE failure)');
130-
} else if(source === 'window.getComputedStyle') {
115+
if(source === 'window.getComputedStyle') {
131116
getComputedStyleCnt++;
132-
} else if(IE_BLACK_LIST.indexOf(lastPart) !== -1) {
133-
logs.push(file + ' : contains .' + lastPart + ' (IE failure)');
134-
} else if(IE_SVG_BLACK_LIST.indexOf(lastPart) !== -1) {
135-
// add special case for sunburst, icicle and treemap where we use 'children'
136-
// off the d3-hierarchy output
137-
var dirParts = path.dirname(file).split(path.sep);
138-
var filename = dirParts[dirParts.length - 1];
139-
var isSunburstOrIcicleOrTreemap =
140-
filename === 'sunburst' ||
141-
filename === 'icicle' ||
142-
filename === 'treemap';
143-
var isLinkedToObject = ['pt', 'd', 'parent', 'node'].indexOf(parts[parts.length - 2]) !== -1;
144-
if(!(isSunburstOrIcicleOrTreemap && isLinkedToObject)) {
145-
logs.push(file + ' : contains .' + lastPart + ' (IE failure in SVG)');
146-
}
147117
}
148118
} else if(node.type === 'Identifier' && node.source() === 'getComputedStyle') {
149119
if(node.parent.source() !== 'window.getComputedStyle') {

test/jasmine/assets/unpolyfill.js

-34
This file was deleted.

test/jasmine/karma.conf.js

-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ if(isFullSuite) {
118118
}
119119

120120
var pathToCustomMatchers = path.join(__dirname, 'assets', 'custom_matchers.js');
121-
var pathToUnpolyfill = path.join(__dirname, 'assets', 'unpolyfill.js');
122121
var pathToSaneTopojsonDist = path.join(__dirname, '..', '..', 'node_modules', 'sane-topojson', 'dist');
123122
var pathToMathJax2 = path.join(__dirname, '..', '..', 'node_modules', 'mathjax-v2');
124123
var pathToMathJax3 = path.join(__dirname, '..', '..', 'node_modules', 'mathjax-v3');
@@ -189,7 +188,6 @@ func.defaultConfig = {
189188
// N.B. the rest of this field is filled below
190189
files: [
191190
pathToCustomMatchers,
192-
pathToUnpolyfill,
193191
// available to fetch from /base/node_modules/mathjax-v2/
194192
// more info: http://karma-runner.github.io/3.0/config/files.html
195193
{pattern: pathToMathJax2 + '/**', included: false, watched: false, served: true},

test/jasmine/tests/download_test.js

-48
Original file line numberDiff line numberDiff line change
@@ -86,54 +86,6 @@ describe('Plotly.downloadImage', function() {
8686
})
8787
.then(done, done.fail);
8888
}, LONG_TIMEOUT_INTERVAL);
89-
90-
it('should produce the right SVG output in IE', function(done) {
91-
// mock up IE behavior
92-
spyOn(Lib, 'isIE').and.callFake(function() { return true; });
93-
spyOn(slzProto, 'serializeToString').and.callFake(function() {
94-
return serializeToString.apply(this, arguments)
95-
.replace(/(\(#)([^")]*)(\))/gi, '(\"#$2\")');
96-
});
97-
var savedBlob;
98-
window.navigator.msSaveBlob = function(blob) { savedBlob = blob; };
99-
100-
var expectedStart = '<svg class=\'main-svg\' xmlns=\'http://www.w3.org/2000/svg\' xmlns:xlink=\'http://www.w3.org/1999/xlink\'';
101-
var plotClip = /clip-path='url\("#clip[0-9a-f]{6}xyplot"\)/;
102-
var legendClip = /clip-path=\'url\("#legend[0-9a-f]{6}"\)/;
103-
104-
Plotly.newPlot(gd, textchartMock.data, textchartMock.layout)
105-
.then(function(gd) {
106-
savedBlob = undefined;
107-
return Plotly.downloadImage(gd, {
108-
format: 'svg',
109-
height: 300,
110-
width: 300,
111-
filename: 'plotly_download'
112-
});
113-
})
114-
.then(function() {
115-
if(savedBlob === undefined) {
116-
fail('undefined saveBlob');
117-
}
118-
119-
return new Promise(function(resolve, reject) {
120-
var reader = new FileReader();
121-
reader.onloadend = function() {
122-
var res = reader.result;
123-
124-
expect(res.substr(0, expectedStart.length)).toBe(expectedStart);
125-
expect(res.match(plotClip)).not.toBe(null);
126-
expect(res.match(legendClip)).not.toBe(null);
127-
128-
resolve();
129-
};
130-
reader.onerror = function(e) { reject(e); };
131-
132-
reader.readAsText(savedBlob);
133-
});
134-
})
135-
.then(done, done.fail);
136-
}, LONG_TIMEOUT_INTERVAL);
13789
});
13890

13991
function downloadTest(gd, format) {

test/jasmine/tests/lib_test.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1853,9 +1853,7 @@ describe('Test lib.js:', function() {
18531853
-Number.MAX_VALUE, -Number.MIN_VALUE
18541854
];
18551855

1856-
if(!Lib.isIE()) {
1857-
vals.push(Number.EPSILON, -Number.EPSILON);
1858-
}
1856+
vals.push(Number.EPSILON, -Number.EPSILON);
18591857

18601858
vals.forEach(function(v) {
18611859
expect(Lib.cleanNumber(v)).toBe(v);

test/jasmine/tests/svg_text_utils_test.js

-22
Original file line numberDiff line numberDiff line change
@@ -349,28 +349,6 @@ describe('svg+text utils', function() {
349349
expect(i).toBe(355);
350350
});
351351

352-
it('decodes arbitrary decimal and hex number entities (IE case)', function() {
353-
// IE does not have String.fromCodePoint
354-
String.fromCodePoint = undefined;
355-
expect(String.fromCodePoint).toBeUndefined();
356-
357-
var i = 0;
358-
for(var n = 33; n < 0x10FFFF; n = Math.round(n * 1.03)) {
359-
var node = mockTextSVGElement(
360-
'&#x' + n.toString(16) +
361-
'; = &#' + n.toString() +
362-
'; = &#x' + n.toString(16).toUpperCase() + ';'
363-
);
364-
var char = stringFromCodePoint(n);
365-
expect(node.text()).toBe(char + ' = ' + char + ' = ' + char, n);
366-
i++;
367-
}
368-
// not really necessary to assert this, but we tested 355 characters,
369-
// weighted toward the low end but continuing all the way to the
370-
// end of the unicode definition
371-
expect(i).toBe(355);
372-
});
373-
374352
it('does not decode entities prematurely', function() {
375353
var testCases = [
376354
'&lt;b>not bold</b&gt;',

0 commit comments

Comments
 (0)