Skip to content

Commit

Permalink
fix window.document errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikaoto committed Aug 31, 2023
1 parent 713a4a9 commit 742e88a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/create/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ export const create = async (App, options = DEFAULT_CREATE_OPTIONS, optionsExter
if (appIsKey) App = {}
await fetchSync(key, options)

if (typeof (document) === 'undefined') window.document = {}
if (typeof (document) === 'undefined') {
if (typeof (window) === 'undefined') window = {}
if (!window.document) window.document = { body: {} }
document = window.document
}
const doc = options.parent || options.document || document
const [scratchSystem, emotion, registry] = initEmotion(key, options)

Expand Down Expand Up @@ -93,7 +97,11 @@ export const createSync = (App, options = DEFAULT_CREATE_OPTIONS, optionsExterna
if (appIsKey) App = {}

// Set parent
if (typeof (document) === 'undefined') window.document = { body: {} }
if (typeof (document) === 'undefined') {
if (typeof (window) === 'undefined') window = {}
if (!window.document) window.document = { body: {} }
document = window.document
}
let parent
if (options.parent) parent = options.parent
else if (options.document) parent = options.document
Expand Down

0 comments on commit 742e88a

Please sign in to comment.