Skip to content

Commit 9d85d2d

Browse files
committed
fix(nuxt3): will correctly detect devtools availability with Vue 3.2.14+
1 parent 3b5d565 commit 9d85d2d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/shell-chrome/src/detector.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ function detect (win) {
1616
let Vue
1717

1818
if (window.$nuxt) {
19-
Vue = window.$nuxt.$root.constructor
19+
Vue = window.$nuxt.$root && window.$nuxt.$root.constructor
2020
}
2121

2222
win.postMessage({
23-
devtoolsEnabled: Vue && Vue.config.devtools,
23+
devtoolsEnabled: (/* Vue 2 */ Vue && Vue.config.devtools) ||
24+
(/* Vue 3.2.14+ */ window.__VUE_DEVTOOLS_GLOBAL_HOOK__ && window.__VUE_DEVTOOLS_GLOBAL_HOOK__.enabled),
2425
vueDetected: true,
2526
nuxtDetected: true
2627
}, '*')
@@ -32,7 +33,7 @@ function detect (win) {
3233
const vueDetected = !!(window.__VUE__)
3334
if (vueDetected) {
3435
win.postMessage({
35-
devtoolsEnabled: window.__VUE_DEVTOOLS_GLOBAL_HOOK__ && window.__VUE_DEVTOOLS_GLOBAL_HOOK__.enabled,
36+
devtoolsEnabled: /* Vue 3.2.14+ */ window.__VUE_DEVTOOLS_GLOBAL_HOOK__ && window.__VUE_DEVTOOLS_GLOBAL_HOOK__.enabled,
3637
vueDetected: true
3738
}, '*')
3839

0 commit comments

Comments
 (0)