From 7b8af01c1e44255804f37b1c57cdc406c6a00697 Mon Sep 17 00:00:00 2001 From: Lebedev Konstantin Date: Wed, 22 Jun 2016 10:37:44 +0300 Subject: [PATCH] * fixes setImmediate --- Sortable.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Sortable.js b/Sortable.js index dc3bd3c..cf3d768 100644 --- a/Sortable.js +++ b/Sortable.js @@ -1246,15 +1246,18 @@ setImmediate = setTimeout; if (win.postMessage && !win.importScripts) { - var postMessageIsAsynchronous = true; - var oldOnMessage = win.onmessage; + var postMessageIsAsynchronous = true; + var oldOnMessage = win.onmessage; - win.onmessage = function () { postMessageIsAsynchronous = false; }; - win.postMessage('', '*'); - win.onmessage = oldOnMessage; + win.onmessage = function () { + postMessageIsAsynchronous = false; + }; - if (postMessageIsAsynchronous) { - var postMessageQueue = []; + win.postMessage('', '*'); + win.onmessage = oldOnMessage; + + if (postMessageIsAsynchronous) { + var postMessageQueue = []; var postMessageEventName = 'sortableSetImmediate:' + expando; var onGlobalMessage = function (event) { if ( @@ -1273,10 +1276,9 @@ setImmediate = function (callback) { postMessageQueue.push(callback); win.postMessage(postMessageEventName, '*'); - return handle; }; - } - } + } + } } // Export utils