diff --git a/ignite-html.js b/ignite-html.js index b7f14ab..2896596 100644 --- a/ignite-html.js +++ b/ignite-html.js @@ -523,20 +523,24 @@ class IgniteRenderingContext { IgniteRenderingContext.ReadyCallbacks.push(callback); //Clear the existing timer if there is one. - if (IgniteRenderingContext.ReadyTimer) { + if (IgniteRenderingContext.ReadyTimer && !IgniteRenderingContext.ReadyTimerRunning) { clearTimeout(IgniteRenderingContext.ReadyTimer); } //Set a new timeout, it will only run once all elements are ready because //of the way single threaded timers work. - IgniteRenderingContext.ReadyTimer = setTimeout(async () => { - for (var i = 0; i < IgniteRenderingContext.ReadyCallbacks.length; i++) { - IgniteRenderingContext.ReadyCallbacks[i].invoke(); - } + if (!IgniteRenderingContext.ReadyTimerRunning) { + IgniteRenderingContext.ReadyTimer = setTimeout(async () => { + IgniteRenderingContext.ReadyTimerRunning = true; + while (IgniteRenderingContext.ReadyCallbacks.length > 0) { + await IgniteRenderingContext.ReadyCallbacks.shift().invoke(); + } - IgniteRenderingContext.ReadyCallbacks = []; - IgniteRenderingContext.ReadyTimer = null; - }, 1); + IgniteRenderingContext.ReadyCallbacks = []; + IgniteRenderingContext.ReadyTimer = null; + IgniteRenderingContext.ReadyTimerRunning = false; + }, 1); + } } static get rendering() { @@ -550,6 +554,7 @@ class IgniteRenderingContext { window.IgniteRenderingContext = IgniteRenderingContext; window.IgniteObject = IgniteObject; +window.IgniteCallback = IgniteCallback; export { IgniteProperty,