javascript - Are an element's dimensions readable immediately upon adding it to the DOM tree? -


Suppose i dynamically create a div using document.createElement , some internal Add text, and want to set its height and width I can see that before adding DOP to the DOM tree, there are properties like offsetWidth and offsetHyight 0 Expected I. Once the program is added to the paste, can I expect those properties to be "ready" immediately? Or is there an atmosphere where there might be delay in charging / Reflow and later?

  textDiv = document createElement ("div"); TextDiv.innerHTML = "Some dynamic build string"; Console.log (textDiv.offsetWidth); // 0 document.body.appendChild (textDiv); Console.log (textDiv.offsetWidth); // Fine?  

I think the answer will be something like this "JavaScript translator is single-threaded and the re-color / reflu event started by append child is part of that thread and continuing the next statement Ends before "... but can anyone see my understanding?

There's a lot I'm looking for but it's not clear how Opera is typical. In any case, it seems that the application developer can take any necessary re-paint / refflo properly, such as taking measurements such as getting offsetwid.

As soon as your element is added to the DOM, it should be available for access as it begins Be it from Simple, simple dom herling is synchronous.

Be careful when you start to start timeouts, intervals, and Ajax.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -