diff --git a/CHANGELOG.md b/CHANGELOG.md index ae039e226a26..ee7f5dc81177 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,6 +103,7 @@ - Fix non-enumerable integer keys issue because of Nashorn ~ JDK8 bug, [#389](https://github.com/zloirock/core-js/issues/389). - Fix [Safari 12.0 `Array#reverse` bug](https://bugs.webkit.org/show_bug.cgi?id=188794). - Fix buggy `String#padStart` and `String#padEnd` mobile Safari implementations, [#414](https://github.com/zloirock/core-js/issues/414). + - One more fix for microtasks in iOS related [#339](https://github.com/zloirock/core-js/issues/339). - Added a fallback for [Rhino bug](https://github.com/mozilla/rhino/issues/346), [#440](https://github.com/zloirock/core-js/issues/440). - Repository: - Change `core-js` repository structure to monorepo with packages in `/packages/` directory. diff --git a/packages/core-js/internals/microtask.js b/packages/core-js/internals/microtask.js index 909b3a1cdcdb..2e28c80e788b 100644 --- a/packages/core-js/internals/microtask.js +++ b/packages/core-js/internals/microtask.js @@ -1,7 +1,8 @@ var global = require('../internals/global'); var classof = require('../internals/classof-raw'); var macrotask = require('../internals/task').set; -var Observer = global.MutationObserver || global.WebKitMutationObserver; +var userAgent = require('../internals/user-agent'); +var MutationObserver = global.MutationObserver || global.WebKitMutationObserver; var process = global.process; var Promise = global.Promise; var queueMicrotask = global.queueMicrotask; @@ -33,11 +34,11 @@ if (!queueMicrotask) { notify = function () { process.nextTick(flush); }; - // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339 - } else if (Observer && !(global.navigator && global.navigator.standalone)) { + // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339 + } else if (MutationObserver && !/(iPhone|iPod|iPad).*AppleWebKit/i.test(userAgent)) { var toggle = true; var node = document.createTextNode(''); - new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new + new MutationObserver(flush).observe(node, { characterData: true }); // eslint-disable-line no-new notify = function () { node.data = toggle = !toggle; };