Skip to content

Commit

Permalink
fix(runtime-dom): apply css vars before mount and before update
Browse files Browse the repository at this point in the history
  • Loading branch information
linzhe141 committed Aug 8, 2024
1 parent 236fb7a commit 63bb92b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/runtime-dom/src/helpers/useCssVars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
type VNode,
getCurrentInstance,
onBeforeMount,
onBeforeUpdate,
onMounted,
onUnmounted,
warn,
Expand Down Expand Up @@ -47,6 +48,10 @@ export function useCssVars(getter: (ctx: any) => Record<string, string>) {
watchPostEffect(setVars)
})

onBeforeUpdate(() => {
watchPostEffect(setVars)
})

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

0 comments on commit 63bb92b

Please sign in to comment.