var global = require('../internals/global');
+var bind = require('../internals/function-bind-context');
var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;
-var classof = require('../internals/classof-raw');
var macrotask = require('../internals/task').set;
var IS_IOS = require('../internals/engine-is-ios');
+var IS_IOS_PEBBLE = require('../internals/engine-is-ios-pebble');
+var IS_WEBOS_WEBKIT = require('../internals/engine-is-webos-webkit');
+var IS_NODE = require('../internals/engine-is-node');
var MutationObserver = global.MutationObserver || global.WebKitMutationObserver;
+var document = global.document;
var process = global.process;
var Promise = global.Promise;
-var IS_NODE = classof(process) == 'process';
// Node.js 11 shows ExperimentalWarning on getting `queueMicrotask`
var queueMicrotaskDescriptor = getOwnPropertyDescriptor(global, 'queueMicrotask');
var queueMicrotask = queueMicrotaskDescriptor && queueMicrotaskDescriptor.value;
if (parent) parent.enter();
};
- // Node.js
- if (IS_NODE) {
- notify = function () {
- process.nextTick(flush);
- };
// browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
- } else if (MutationObserver && !IS_IOS) {
+ // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898
+ if (!IS_IOS && !IS_NODE && !IS_WEBOS_WEBKIT && MutationObserver && document) {
toggle = true;
node = document.createTextNode('');
new MutationObserver(flush).observe(node, { characterData: true });
node.data = toggle = !toggle;
};
// environments with maybe non-completely correct, but existent Promise
- } else if (Promise && Promise.resolve) {
+ } else if (!IS_IOS_PEBBLE && Promise && Promise.resolve) {
// Promise.resolve without an argument throws an error in LG WebOS 2
promise = Promise.resolve(undefined);
- then = promise.then;
+ // workaround of WebKit ~ iOS Safari 10.1 bug
+ promise.constructor = Promise;
+ then = bind(promise.then, promise);
notify = function () {
- then.call(promise, flush);
+ then(flush);
+ };
+ // Node.js without promises
+ } else if (IS_NODE) {
+ notify = function () {
+ process.nextTick(flush);
};
// for other environments - macrotask based on:
// - setImmediate
// - onreadystatechange
// - setTimeout
} else {
+ // strange IE + webpack dev server bug - use .bind(global)
+ macrotask = bind(macrotask, global);
notify = function () {
- // strange IE + webpack dev server bug - use .call(global)
- macrotask.call(global, flush);
+ macrotask(flush);
};
}
}