Skip to content

Commit d2394cc

Browse files
authored
fix: do not use useStyleTag in SPA slides (#2078)
1 parent eb4046f commit d2394cc

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/client/internals/SlideContainer.vue

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
2-
import { provideLocal, useElementSize, useStyleTag } from '@vueuse/core'
3-
import { computed, ref } from 'vue'
2+
import { provideLocal, useElementSize } from '@vueuse/core'
3+
import { computed, onUnmounted, ref, watchEffect } from 'vue'
44
import { useNav } from '../composables/useNav'
55
import { injectionSlideElement, injectionSlideScale } from '../constants'
66
import { slideAspect, slideHeight, slideWidth } from '../env'
@@ -64,8 +64,11 @@ const containerStyle = computed(() => props.width
6464
: {},
6565
)
6666
67-
if (props.isMain)
68-
useStyleTag(computed(() => `:root { --slidev-slide-scale: ${scale.value}; }`))
67+
if (props.isMain) {
68+
const rootStyle = document.documentElement.style
69+
watchEffect(() => rootStyle.setProperty('--slidev-slide-scale', scale.value.toString()))
70+
onUnmounted(() => rootStyle.removeProperty('--slidev-slide-scale'))
71+
}
6972
7073
provideLocal(injectionSlideScale, scale)
7174
provideLocal(injectionSlideElement, slideElement)

0 commit comments

Comments
 (0)