fix(core): update

This commit is contained in:
Philipp Kunz 2020-05-25 16:11:59 +00:00
parent 455d68338b
commit c2e0c0ab19

View File

@ -10,8 +10,8 @@ export class DomTools {
// lets make sure the dom is ready // lets make sure the dom is ready
const readyStateChangedFunc = () => { const readyStateChangedFunc = () => {
if (document.readyState === 'interactive' || document.readyState === 'complete') { if (document.readyState === 'interactive' || document.readyState === 'complete') {
domToolsInstance.headElement = document.querySelector('head'); domToolsInstance.elements.headElement = document.querySelector('head');
domToolsInstance.bodyElement = document.querySelector('body'); domToolsInstance.elements.bodyElement = document.querySelector('body');
domToolsInstance.domReady.resolve(); domToolsInstance.domReady.resolve();
} }
}; };
@ -24,20 +24,27 @@ export class DomTools {
return domToolsInstance; return domToolsInstance;
} }
public smartstate = new plugins.smartstate.Smartstate();
public domToolsReady = plugins.smartpromise.defer(); public domToolsReady = plugins.smartpromise.defer();
public domReady = plugins.smartpromise.defer(); public domReady = plugins.smartpromise.defer();
public globalStylesReady = plugins.smartpromise.defer(); public globalStylesReady = plugins.smartpromise.defer();
// elements // elements
public headElement: HTMLElement; public elements: {
public bodyElement: HTMLElement; headElement: HTMLElement;
bodyElement: HTMLElement;
} = {
headElement: null,
bodyElement: null,
};
public async setGlobalStyles(stylesText: string) { public async setGlobalStyles(stylesText: string) {
await this.domReady.promise; await this.domReady.promise;
const styleElement = document.createElement('style'); const styleElement = document.createElement('style');
styleElement.type = 'text/css'; styleElement.type = 'text/css';
styleElement.appendChild(document.createTextNode(stylesText)); styleElement.appendChild(document.createTextNode(stylesText));
this.headElement.appendChild(styleElement); this.elements.headElement.appendChild(styleElement);
} }
private runOnceTrackerStringMap = new Stringmap(); private runOnceTrackerStringMap = new Stringmap();