What do you think about the following?
var starter;
starter = $.Deferred();
starter.then(function () {
console.log('promiseOne done');
});
starter.resolve();
var now=new Date().getTime();
var stop=now+5000;
while (stop>new Date().getTime()){}
console.log('main thread finished');
In jQuery-1.11.1, we get:
promiseOne done
main thread finished
which is obviously wrong and in jQuery 3.0, we get:
main thread finished
promiseOne done
which is hopefully what we expect, since promise callbacks are executed asynchronously.
However, by replacing .then with .done, in both cases I am getting:
promiseOne done
main thread finished
What is going on here? Is that still a bug of jQuery 3.0 or .done callbacks are executed synchronously?