From: Evan You Date: Thu, 23 Sep 2021 15:53:00 +0000 (-0400) Subject: refactor: use getGlobalThis when attachting hmr runtime X-Git-Tag: v3.2.17~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1e5a0db4d48528b408bb373c2adf907b1da0cbff;p=thirdparty%2Fvuejs%2Fcore.git refactor: use getGlobalThis when attachting hmr runtime --- diff --git a/packages/runtime-core/src/hmr.ts b/packages/runtime-core/src/hmr.ts index 358fa843b9..3bd5ef88bc 100644 --- a/packages/runtime-core/src/hmr.ts +++ b/packages/runtime-core/src/hmr.ts @@ -8,7 +8,7 @@ import { isClassComponent } from './component' import { queueJob, queuePostFlushCb } from './scheduler' -import { extend } from '@vue/shared' +import { extend, getGlobalThis } from '@vue/shared' export let isHmrUpdating = false @@ -26,16 +26,7 @@ export interface HMRRuntime { // Note: for a component to be eligible for HMR it also needs the __hmrId option // to be set so that its instances can be registered / removed. if (__DEV__) { - const globalObject: any = - typeof global !== 'undefined' - ? global - : typeof self !== 'undefined' - ? self - : typeof window !== 'undefined' - ? window - : {} - - globalObject.__VUE_HMR_RUNTIME__ = { + getGlobalThis().__VUE_HMR_RUNTIME__ = { createRecord: tryWrap(createRecord), rerender: tryWrap(rerender), reload: tryWrap(reload)