javascript - Injecting style tag + angular component timing -


i have following piece of code:

//load theme await theme.load('light');  $state.go('viewer'); 

theme.load loads sass file, compiles it, , injects style tag this:

let themestyles = document.head.queryselector('style#theme');  if(!themestyles) {     themestyles = document.createelement('style');     themestyles.setattribute('id', 'theme');     document.head.appendchild(themestyles); }  themestyles.textcontent = await importer.import('sass/themes/'+theme+'.scss'); 

here's template viewer state:

<map></map> <top-left-menu></top-left-menu> <loader></loader> 

and here's map component:

.component('map', {     controller: ['$element', mapcontroller] });  function mapcontroller($element, map) {     this.$oninit = () => {         console.log(document.head.queryselector('style#theme').textcontent);         console.log($element[0].getboundingclientrect())     } } 

the first console log prints injected css expected, getclientboundingrect() function returning width:0 , height:0, though $state.go executed after theme.load returns , css injected. tried $postlink, same thing. tried replacing async/await regular promises (could weird babel behaviour), same thing. ~100ms settimeout element report correct size.

i wonder if related how styles , dom computed, or way angular sets components. ideas?

found out answer - external font being loaded through @import tag delaying css evaluation.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -