From 97d8b5ed88b8e3eaa093f10ae0fa3737fe38790c Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Mon, 13 Aug 2018 17:12:34 -0700 Subject: [PATCH] fix(ivy): reordering how root is acquired (#25470) PR Close #25470 --- packages/core/src/render3/ng_dev_mode.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core/src/render3/ng_dev_mode.ts b/packages/core/src/render3/ng_dev_mode.ts index 776d5935c1..90f48c8237 100644 --- a/packages/core/src/render3/ng_dev_mode.ts +++ b/packages/core/src/render3/ng_dev_mode.ts @@ -37,9 +37,11 @@ declare global { declare let global: any; +// NOTE: The order here matters: Checking window, then global, then self is important. +// checking them in another order can result in errors in some Node environments. const __global: {ngDevMode: NgDevModePerfCounters | boolean} = - typeof window != 'undefined' && window || typeof self != 'undefined' && self || - typeof global != 'undefined' && global; + typeof window != 'undefined' && window || typeof global != 'undefined' && global || + typeof self != 'undefined' && self; export function ngDevModeResetPerfCounters(): NgDevModePerfCounters { // Make sure to refer to ngDevMode as ['ngDevMode'] for clousre.