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

Commit 038bdd9

Browse files
committedMay 8, 2015
feat(scheduling): Prefer MutationObserver over Promise in FF
see https://bugzilla.mozilla.org/show_bug.cgi?id=1162013
1 parent 74eff1c commit 038bdd9

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed
 

‎dist/zone-microtask.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -1135,12 +1135,13 @@ module.exports = {
11351135
// TODO(vicb): Create a benchmark for the different methods & the usage of the queue
11361136
// see https://github.com/angular/zone.js/issues/97
11371137

1138-
var hasNativePromise = false;
11391138
var len = 0;
11401139

1141-
if (typeof Promise ==! "undefined" && Promise.toString().indexOf("[native code]") !== -1) {
1142-
hasNativePromise = true;
1143-
}
1140+
var hasNativePromise = typeof Promise ==! "undefined" &&
1141+
Promise.toString().indexOf("[native code]") !== -1;
1142+
1143+
var isFirefox = global.navigator &&
1144+
global.navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
11441145

11451146
function asap(callback) {
11461147
queue[len] = callback;
@@ -1206,7 +1207,9 @@ function flush() {
12061207

12071208
var scheduleFlush;
12081209
// Decide what async method to use to triggering processing of queued callbacks:
1209-
if (hasNativePromise) {
1210+
if (hasNativePromise && !isFirefox) {
1211+
// TODO(vicb): remove '!isFirefox' when the bug is fixed:
1212+
// https://bugzilla.mozilla.org/show_bug.cgi?id=1162013
12101213
scheduleFlush = usePromise();
12111214
} else if (BrowserMutationObserver) {
12121215
scheduleFlush = useMutationObserver();

0 commit comments

Comments
 (0)