]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor: use getGlobalThis when attachting hmr runtime
authorEvan You <yyx990803@gmail.com>
Thu, 23 Sep 2021 15:53:00 +0000 (11:53 -0400)
committerEvan You <yyx990803@gmail.com>
Thu, 23 Sep 2021 15:53:00 +0000 (11:53 -0400)
packages/runtime-core/src/hmr.ts

index 358fa843b9b1cf0fe6e0f5f4d3ace14d6657a8bc..3bd5ef88bc3d45a11ff3386fee6ebd6da5e49d9c 100644 (file)
@@ -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)