mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2024-11-28 18:15:37 -05:00
Updating preprocessAndLoadCss to work async
This commit is contained in:
parent
6e0356ef68
commit
b4b79d82ee
1 changed files with 10 additions and 4 deletions
|
@ -59,13 +59,19 @@ export function preprocessAndLoad (url) {
|
|||
* Also rewrites all instances of url() with a different base
|
||||
*/
|
||||
export function preprocessAndLoadCss (baseUrl, url) {
|
||||
document.write('<!-- ' + url + '-->\n');
|
||||
document.write('<style type=\'text/css\'>\n');
|
||||
var cssData = preprocessAndLoad(url);
|
||||
cssData = cssData.replace(/url\('/g, 'url(\'' + baseUrl + '/');
|
||||
cssData = cssData.replace(/url\(([^'])/g, 'url(' + baseUrl + '/$1');
|
||||
document.write(cssData);
|
||||
document.write('\n</style>\n');
|
||||
|
||||
const head = document.head;
|
||||
let style = document.createElement('style');
|
||||
style.type = 'text/css';
|
||||
if (style.styleSheet){
|
||||
style.styleSheet.cssText = cssData;
|
||||
} else {
|
||||
style.appendChild(document.createTextNode(cssData));
|
||||
}
|
||||
head.appendChild(style);
|
||||
}
|
||||
|
||||
export function rl () {
|
||||
|
|
Loading…
Reference in a new issue