Skip to content

Commit

Permalink
Fix #9653 force load of font when fontAwesome css is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
MV88 committed Nov 29, 2023
1 parent 170bce7 commit 6440622
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions web/client/utils/styleparser/StyleParserUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ export const parseSymbolizerExpressions = (symbolizer, feature) => {
};


let loaded = false;
const loadFontAwesome = () => {
return new Promise((resolve) => {
const fontAwesomeHref = 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css';
Expand All @@ -862,13 +863,25 @@ const loadFontAwesome = () => {
fontAwesome.setAttribute('href', fontAwesomeHref);
document.head.appendChild(fontAwesome);
fontAwesome.onload = () => {
resolve();
const font = document.createElement('link');
font.setAttribute('rel', 'preload');
font.setAttribute('as', 'font');
font.setAttribute('crossorigin', true);
font.setAttribute('href', "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/fonts/fontawesome-webfont.woff?v=4.7.0");
document.head.appendChild(font);
font.onload = () => {
loaded = true;
resolve();
};
};
fontAwesome.onerror = () => {
resolve();
};
} else {
resolve();
if (loaded) {
// delaying the resolve to make sure the fontAwesome.onload is triggered before
resolve();
}
}
});
};
Expand Down

0 comments on commit 6440622

Please sign in to comment.