-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathie-31-css-fix.js
35 lines (31 loc) · 964 Bytes
/
ie-31-css-fix.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
* Fix 31 css bug in IE (9 and less)
* https://github.com/lusever/ie31css
* MIT licensed
*/
function fixIESheets() {
var linksList = document.getElementsByTagName('link'),
links = [],
i, style, styleSheet;
for (i = linksList.length - 1; i >= 0; i = i - 1) {
if (linksList[i].rel === 'stylesheet' && linksList[i].href) {
links.push(linksList[i]);
}
}
// remove all but first
for (i = links.length - 1; i >= 1; i = i - 1) {
links[i].removeNode();
}
// create new style with imports
for (i = links.length - 1; i >= 0; i = i - 1) {
if (!styleSheet || styleSheet.imports.length === 30) {
style = document.createElement('style');
links[0].insertAdjacentElement('afterEnd', style);
styleSheet = style.styleSheet;
}
styleSheet.addImport(links[i].href);
}
if (links[0]) {
links[0].removeNode();
}
}