2021-01-03 14:25:43 +05:30
|
|
|
export function loadCSSFile(path) {
|
2021-03-08 18:12:59 +05:30
|
|
|
return new Promise((resolve) => {
|
2021-01-29 00:20:46 +05:30
|
|
|
if (!path) resolve();
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
if (document.querySelector(`link[href="${path}"]`)) {
|
|
|
|
resolve();
|
|
|
|
} else {
|
|
|
|
const linkElement = document.createElement('link');
|
|
|
|
linkElement.type = 'text/css';
|
|
|
|
linkElement.rel = 'stylesheet';
|
|
|
|
// eslint-disable-next-line @gitlab/require-i18n-strings
|
|
|
|
linkElement.media = 'screen,print';
|
|
|
|
linkElement.onload = () => {
|
|
|
|
resolve();
|
|
|
|
};
|
|
|
|
linkElement.href = path;
|
|
|
|
|
|
|
|
document.head.appendChild(linkElement);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|