Index: src/object-observe.js |
diff --git a/src/object-observe.js b/src/object-observe.js |
index 499b27eca1bef61b76b367f591fbc66413cd09bd..7bed924abaa2b3d113bdf9d7d3fdb38d4af385c5 100644 |
--- a/src/object-observe.js |
+++ b/src/object-observe.js |
@@ -63,6 +63,7 @@ if (IS_UNDEFINED(observationState.callbackInfoMap)) { |
observationState.notifierObjectInfoMap = %ObservationWeakMapCreate(); |
observationState.pendingObservers = null; |
observationState.nextCallbackPriority = 0; |
+ observationState.microtaskScheduled = false; |
} |
function ObservationWeakMap(map) { |
@@ -394,7 +395,7 @@ function ObserverEnqueueIfActive(observer, objectInfo, changeRecord, |
observationState.pendingObservers = nullProtoObject(); |
observationState.pendingObservers[callbackInfo.priority] = callback; |
callbackInfo.push(changeRecord); |
- %SetMicrotaskPending(true); |
+ EnqueueObserveMicrotask(); |
} |
function ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord, type) { |
@@ -575,6 +576,7 @@ function ObjectDeliverChangeRecords(callback) { |
} |
function ObserveMicrotaskRunner() { |
+ observationState.microtaskScheduled = false; |
var pendingObservers = observationState.pendingObservers; |
if (pendingObservers) { |
observationState.pendingObservers = null; |
@@ -583,7 +585,15 @@ function ObserveMicrotaskRunner() { |
} |
} |
} |
-RunMicrotasks.runners.push(ObserveMicrotaskRunner); |
+ |
+function EnqueueObserveMicrotask() { |
+ if (observationState.microtaskScheduled) |
+ return; |
+ |
+ RunMicrotasks.queue.push(ObserveMicrotaskRunner); |
+ %SetMicrotaskPending(true); |
+ observationState.microtaskScheduled = true; |
+} |
function SetupObjectObserve() { |
%CheckIsBootstrapping(); |