From 3aa0b95e1d8dd6a52885abf3a3760ce7462d74bd Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Tue, 23 Apr 2024 14:11:12 +0000 Subject: [PATCH] refactor(core): set up framework injector profile exclusively when `WeakRef` is defined In some cases in G3 `WeakRef` is undefined because some tests are executed on older unsupported browsers. --- packages/core/src/render3/util/global_utils.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core/src/render3/util/global_utils.ts b/packages/core/src/render3/util/global_utils.ts index e96704672b873..8fe60a3b8ca4c 100644 --- a/packages/core/src/render3/util/global_utils.ts +++ b/packages/core/src/render3/util/global_utils.ts @@ -71,8 +71,9 @@ export function publishDefaultGlobalUtils() { if (!_published) { _published = true; - if (typeof window !== 'undefined') { - // Only configure the injector profiler when running in the browser. + // Only configure the injector profiler when running in the browser and WeakRef is defined. + // In some G3 tests WeakRef is undefined as they user older (unsupported) browsers to test. + if (typeof window !== 'undefined' && typeof WeakRef !== 'undefined') { setupFrameworkInjectorProfiler(); }