Skip to content

Commit

Permalink
don't use MutationObserver in iOS completely, fixes #455, #339
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Dec 3, 2018
1 parent 87276fb commit 3e75f32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 5 additions & 4 deletions packages/core-js/internals/microtask.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
};
Expand Down

0 comments on commit 3e75f32

Please sign in to comment.