Skip to content

Commit

Permalink
fix(runtime-dom): apply css vars before mount (#11538)
Browse files Browse the repository at this point in the history
fix #11533
  • Loading branch information
linzhe141 committed Aug 7, 2024
1 parent e359ff0 commit fdc2a31
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/runtime-dom/src/helpers/useCssVars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Static,
type VNode,
getCurrentInstance,
onBeforeMount,
onMounted,
onUnmounted,
warn,
Expand Down Expand Up @@ -42,8 +43,11 @@ export function useCssVars(getter: (ctx: any) => Record<string, string>) {
updateTeleports(vars)
}

onMounted(() => {
onBeforeMount(() => {
watchPostEffect(setVars)
})

onMounted(() => {
const ob = new MutationObserver(setVars)
ob.observe(instance.subTree.el!.parentNode, { childList: true })
onUnmounted(() => ob.disconnect())
Expand Down

0 comments on commit fdc2a31

Please sign in to comment.