2020-05-23 15:00:01 +00:00
|
|
|
import { defer } from '@pushrocks/smartpromise';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* a basic setup for elements
|
|
|
|
* makes sure everything is in check
|
|
|
|
*/
|
|
|
|
export const elementBasicSetup = async () => {
|
|
|
|
if (globalThis.deesCssToolsReady) {
|
|
|
|
await globalThis.deesCssToolsReady.promise;
|
|
|
|
} else {
|
|
|
|
globalThis.deesCssToolsReady = defer();
|
2020-05-23 15:40:08 +00:00
|
|
|
const documentReady = defer();
|
|
|
|
document.onreadystatechange = () => {
|
|
|
|
if (document.readyState === 'interactive') {
|
|
|
|
documentReady.resolve();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
await documentReady.promise;
|
|
|
|
const head = document.querySelector('head');
|
|
|
|
const styleElement = document.createElement('style');
|
|
|
|
styleElement.type = 'text/css';
|
|
|
|
styleElement.appendChild(document.createTextNode(materialFontCss));
|
2020-05-23 15:00:01 +00:00
|
|
|
globalThis.deesCssToolsReady.resolve();
|
|
|
|
}
|
|
|
|
};
|