diff --git a/lib/utils/browser/dom_service/dom_service.dart b/lib/utils/browser/dom_service/dom_service.dart index 225645dc4..6e999261a 100644 --- a/lib/utils/browser/dom_service/dom_service.dart +++ b/lib/utils/browser/dom_service/dom_service.dart @@ -23,6 +23,18 @@ typedef Future RequestAnimationFrame(); /// Utility class to synchronize DOM operations across components, e.g. to check /// changes in the layout after a UI update or application event. class DomService { + /// Whether to execute functions scheduled within [Zone.current]. + /// + /// This is the expected behavior and contract of Dart applications, but is + /// not applied automatically to every callback (only to Futures and Streams). + /// Eventually, this flag will be flipped to `true`, and deleted (all code + /// must use this behavior). + /// + /// By flipping this to `true`, it means: + /// * [Zone.current] will be restored when the callbacks are executed. + /// * AngularDart (or any parent zone) will know about the change. + static bool maintainZoneOnCallbacks = false; + static const _TURN_DONE_EVENT_TYPE = 'doms-turn'; /// The maximum time the idle scheduler waits between events. @@ -241,6 +253,9 @@ class DomService { } void _scheduleInQueue(DomReadWriteFn fn, List queue) { + if (maintainZoneOnCallbacks) { + fn = Zone.current.bindCallback(fn); + } queue.add(fn); _scheduleProcessQueue(); }