We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d32b459 commit 223d069Copy full SHA for 223d069
packages/core/createGlobalState/index.ts
@@ -1,16 +1,23 @@
1
import { createApp, reactive } from 'vue-demi'
2
+import { defaultDocument } from '../_configurable'
3
4
function withScope<T extends object>(factory: () => T): T {
- const container = document.createElement('div')
5
-
6
let state: T = null as any
7
8
- createApp({
9
- setup() {
10
- state = reactive(factory()) as T
11
- },
12
- render: () => null,
13
- }).mount(container)
+ const document = defaultDocument
+
+ if (document) {
+ const container = document.createElement('div')
+ createApp({
+ setup() {
+ state = reactive(factory()) as T
14
+ },
15
+ render: () => null,
16
+ }).mount(container)
17
+ }
18
+ else {
19
20
21
22
return state
23
}
0 commit comments