Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
feat(scheduling): Prefer MutationObserver over Promise in FF
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb committed May 8, 2015
1 parent 74eff1c commit 038bdd9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
13 changes: 8 additions & 5 deletions dist/zone-microtask.js
Original file line number Diff line number Diff line change
Expand Up @@ -1135,12 +1135,13 @@ module.exports = {
// TODO(vicb): Create a benchmark for the different methods & the usage of the queue
// see https://github.com/angular/zone.js/issues/97

var hasNativePromise = false;
var len = 0;

if (typeof Promise ==! "undefined" && Promise.toString().indexOf("[native code]") !== -1) {
hasNativePromise = true;
}
var hasNativePromise = typeof Promise ==! "undefined" &&
Promise.toString().indexOf("[native code]") !== -1;

var isFirefox = global.navigator &&
global.navigator.userAgent.toLowerCase().indexOf('firefox') > -1;

function asap(callback) {
queue[len] = callback;
Expand Down Expand Up @@ -1206,7 +1207,9 @@ function flush() {

var scheduleFlush;
// Decide what async method to use to triggering processing of queued callbacks:
if (hasNativePromise) {
if (hasNativePromise && !isFirefox) {
// TODO(vicb): remove '!isFirefox' when the bug is fixed:
// https://bugzilla.mozilla.org/show_bug.cgi?id=1162013
scheduleFlush = usePromise();
} else if (BrowserMutationObserver) {
scheduleFlush = useMutationObserver();
Expand Down
Loading

0 comments on commit 038bdd9

Please sign in to comment.