Skip to content

Commit d1012b5

Browse files
authored
Fixed functions in _addFile.
Fixture #1: Due to lack of browser support for the attribute selector insensitive flag (i), I changed it out for a function that works for all browsers including IE11. Fixture #2: Due to lack of support in IE11 for Array.prototype.includes(), I changed it out for indexOf which works in all browsers.
1 parent fb8d8e5 commit d1012b5

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

JavaScript/horizontal_timeline.2.0.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,16 +1410,30 @@ Docs at http://horizontal-timeline.ycodetech.co.uk
14101410
css = type == 'css';
14111411

14121412
// If js, check if the lowercase form of the name is in a src attribute in a <script> tag
1413-
if(js) fileExists = $('script[src*="'+name+'" i]');
1413+
if(js)
1414+
// Using fileExists = $('script[src*="'+name+'" i]'); would be more appropriate,
1415+
// but due to lack of browser support, it can't be used yet.
1416+
fileExists = $('link[href*="'+name+'"').filter(function() {
1417+
return this.value.toLowerCase() == name;
1418+
});
1419+
14141420
// Else if css, check if the lowercase form of the name is in a href attribute in a <link> tag
1415-
else if (css) fileExists = $('link[href*="'+name+'" i]');
1421+
else if (css)
1422+
// Using fileExists = $('link[href*="'+name+'" i]'); would be more appropriate,
1423+
// but due to lack of browser support, it can't be used yet.
1424+
fileExists = $('link[href*="'+name+'"').filter(function() {
1425+
return this.value.toLowerCase() == name;
1426+
});
14161427

14171428
// If loadedFile is undefined/not set, create a new array for the loaded files.
14181429
if (loadedFile == undefined) loadedFile = new Array();
14191430

14201431
// If loadedFile array doesn't include the url AND
14211432
// the file doesn't exist in the document...
1422-
if (!loadedFile.includes(url) && !fileExists.length) {
1433+
1434+
// Using !loadedFile.includes(url) would be more ideal,
1435+
// but due to no support in IE11, we can't use it.
1436+
if (loadedFile.indexOf(url) == -1 && !fileExists.length) {
14231437
// File isn't loaded yet...
14241438
// If adding js...
14251439
if(js) {
@@ -1449,7 +1463,10 @@ Docs at http://horizontal-timeline.ycodetech.co.uk
14491463
}
14501464
// Else if the file exists in the document AND
14511465
// the URL isn't in the loadedFile array...
1452-
else if (fileExists.length && !loadedFile.includes(url)) {
1466+
1467+
// Using !loadedFile.includes(url) would be more ideal,
1468+
// but due to no support in IE11, we can't use it.
1469+
else if (fileExists.length && loadedFile.indexOf(url) == -1) {
14531470
// The file is already loaded in the document via a <script> tag...
14541471
if(js) {
14551472
console.log(name+' has already been loaded by a <script> tag in the document, no need to load it again. Timeline instance:', this.$element);

0 commit comments

Comments
 (0)