You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem is that without setTimeout to clear the stack - the stack can get riduncuously big - which then a real problem to try to use the Web Inspector with break points etc.
From my experiments I found that the following setZeroTimeout was the best of the ones on the web :
// Only add setZeroTimeout to the window object, and hide everything else in a closure.
(function() {
var timeouts = [],
messageName = 'zero-timeout-message';
// Like setTimeout, but only takes a function argument. There's
// no time argument (always zero) and no arguments (you have to
// use a closure).
function setZeroTimeoutPostMessage(fn) {
timeouts.push(fn);
window.postMessage(messageName, '*');
}
function setZeroTimeout(fn) {
setTimeout(fn, 0);
}
function handleMessage(event) {
if (event.source == window && event.data == messageName) {
if (event.stopPropagation) {
event.stopPropagation();
}
if (timeouts.length) {
timeouts.shift()();
}
}
}
if (window.postMessage) {
if (window.addEventListener) {
window.addEventListener('message', handleMessage, true);
} else if (window.attachEvent) {
window.attachEvent('onmessage', handleMessage);
}
window.setZeroTimeout = setZeroTimeoutPostMessage;
} else {
window.setZeroTimeout = setZeroTimeout;
}
}());
The text was updated successfully, but these errors were encountered:
Problem is that without setTimeout to clear the stack - the stack can get riduncuously big - which then a real problem to try to use the Web Inspector with break points etc.
From my experiments I found that the following setZeroTimeout was the best of the ones on the web :
The text was updated successfully, but these errors were encountered: