fix loading css on Safari 5 and other older browser

This commit is contained in:
rolux 2014-01-15 09:57:51 +00:00
parent 8e0c2c02f6
commit 0fd84ba156

View file

@ -127,6 +127,11 @@ Ox.getAsync = function(urls, get, callback) {
}
head.appendChild(element);
}
if (type == 'stylesheet') {
//fixme only call if browser does not support onload
// Safari 5 does not fire onload
waitForCSS();
}
}
} else {
callback(cache[url], null);
@ -145,6 +150,18 @@ Ox.getAsync = function(urls, get, callback) {
callback(cache[url], null);
}
}
function waitForCSS() {
var error = false;
try {
element.sheet.cssRule;
} catch (e) {
error = true;
setTimeout(function() {
waitForCSS();
}, 25);
}
!error && onLoad();
}
}
function getFiles(type, urls, callback) {