SOLVED module updateDom() call limitations
I was helping update a module, and it just so happened that there were three updateDom() (no delay) calls back to back… and the changes for the last two were not actually applied to the dom (well, no displayed info changed).
by adding a small delay updateDom(100), everything works, even tho the calls are still back to back…
anyone have an explanation, is this a limitation, a bug, or a limitation in electron?
the content was a different icon without flashing and a change of text to blanks… so, pretty significant…
the app (mmm-voice), completely rebuilt its div contribution to the content, so it would be a significant change… (rip out old, insert new)…
Maybe not a direct answer to your question, but i found out, that updateDom() is not always needed if you “only” want to update some content.
As example i have a (inital) div like:
var Receiverinfo = document.createElement("div"); Receiverinfo.setAttribute('id','model'); Receiverinfo.innerHTML = '';
you can change the value/content by
document.getElementById('model').innerHTML = 'what ever value you want';
Yes, you can fiddle w the dom directly, but you shouldn’t…
so, this turns out to be a side effect of the dom api content update process…
element.appendChild() is an async call… so the update is NOT complete when the call returns.
our getDom() routines use this all the time
updateDom() uses this to check to see if there is an actual content update…
MM wraps the output of getDom() in ANOTHER div, which is added via appendchild, then adds the getDom() content to THAT div via appendChild()…
the next updateDom() call comes in calls getDom(), and checks to see if the new content changed… it creates a div, adds the new content via appendChild() and then compares… sadly, both are still just < div>, so they match, no update needed, and the new content is lost…
SO, the workaround… NEVER call updateDom() without a minimum count of 2 (as the code divides by 2 inside)
it does a hide/update/show) (hide/show each get 1/2 the time specified, ie 2/2 =1 each.