Skip to content

Commit 453ca08

Browse files
author
Martins Barinskis
committed
Merge pull request #1 from Aeriandi/master
Load now checks to see if the style has already been loaded first.
2 parents 37f8c5e + d419252 commit 453ca08

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

css.js

+19-12
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,32 @@
1414
};
1515

1616
define({
17-
load: function(name, req, load) {
18-
var link = createLink(name),
19-
head = doc.getElementsByTagName('head')[0],
20-
test, interval;
17+
load: function (name, req, load) {
18+
var head = doc.getElementsByTagName('head')[0],
19+
test,
20+
interval,
21+
link;
2122

2223
test = doc.createElement('div');
2324
test.className = resolveClassName(name);
2425
test.style.cssText = 'position: absolute;left:-9999px;top:-9999px;';
2526
docBody.appendChild(test);
2627

27-
head.appendChild(link);
28+
if (test.offsetHeight > 0) {
29+
docBody.removeChild(test);
30+
load();
31+
} else {
32+
link = createLink(name),
33+
head.appendChild(link);
2834

29-
interval = win.setInterval(function() {
30-
if (test.offsetHeight > 0) {
31-
clearInterval(interval);
32-
docBody.removeChild(test);
33-
load(link);
34-
}
35-
}, 50);
35+
interval = win.setInterval(function () {
36+
if (test.offsetHeight > 0) {
37+
clearInterval(interval);
38+
docBody.removeChild(test);
39+
load(link);
40+
}
41+
}, 50);
42+
}
3643
}
3744
});
3845
})(window);

0 commit comments

Comments
 (0)