Просмотр исходного кода

fix(devtool): improve devtools late injection browser env detection (#4890)

yuuang 4 лет назад
Родитель
Сommit
fa2237f1d8
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      packages/runtime-core/src/devtools.ts

+ 4 - 1
packages/runtime-core/src/devtools.ts

@@ -55,7 +55,10 @@ export function setDevtoolsHook(hook: DevtoolsHook, target: any) {
     // (#4815)
     // eslint-disable-next-line no-restricted-globals
     typeof window !== 'undefined' &&
-    !navigator.userAgent.includes('jsdom')
+    // some envs mock window but not fully
+    window.HTMLElement &&
+    // also exclude jsdom
+    !window.navigator?.userAgent?.includes('jsdom')
   ) {
     const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
       target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [])