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