From 58b4ab6d7ac30b85ff93f4e7a3b16fc7e6977d07 Mon Sep 17 00:00:00 2001 From: Bram Gotink Date: Tue, 13 Apr 2021 19:11:43 +0200 Subject: [PATCH] fix(cdk/testing): prevent duplicate subscription (#22460) If the actual subscription provided by the environment comes after the first batched function call, the default function is installed and without this change it'll stay installed forever, even if another handler is installed afterwards. --- src/cdk/testing/change-detection.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cdk/testing/change-detection.ts b/src/cdk/testing/change-detection.ts index 648c01a9236a..686084544651 100644 --- a/src/cdk/testing/change-detection.ts +++ b/src/cdk/testing/change-detection.ts @@ -69,7 +69,7 @@ async function batchChangeDetection(fn: () => Promise, triggerBeforeAndAft // If nothing is handling change detection batching, install the default handler. if (!autoChangeDetectionSubscription) { - autoChangeDetectionSubject.subscribe(defaultAutoChangeDetectionHandler); + handleAutoChangeDetectionStatus(defaultAutoChangeDetectionHandler); } if (triggerBeforeAndAfter) {