File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -49,17 +49,20 @@ watch(
49
49
},
50
50
)
51
51
52
- // reset theme
53
- watch ([theme , previewTheme ], ([theme , previewTheme ]) => {
54
- if (! previewTheme ) return
52
+ function switchPreviewTheme() {
53
+ if (! previewTheme .value ) return
55
54
56
55
const html = sandbox .contentDocument ?.documentElement
57
56
if (html ) {
58
- html .className = theme
57
+ html .className = theme . value
59
58
} else {
59
+ // re-create sandbox
60
60
createSandbox ()
61
61
}
62
- })
62
+ }
63
+
64
+ // reset theme
65
+ watch ([theme , previewTheme ], switchPreviewTheme )
63
66
64
67
onUnmounted (() => {
65
68
proxy .destroy ()
@@ -164,6 +167,7 @@ function createSandbox() {
164
167
sandbox .addEventListener (' load' , () => {
165
168
proxy .handle_links ()
166
169
stopUpdateWatcher = watchEffect (updatePreview )
170
+ switchPreviewTheme ()
167
171
})
168
172
}
169
173
You can’t perform that action at this time.
0 commit comments