fix(sfc): fix style variables injection on static vnode (#3847)

fix #3841
This commit is contained in:
edison
2021-07-15 06:08:12 +08:00
committed by GitHub
parent 03e26845e2
commit 6a0c7cd905
2 changed files with 40 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ import {
ref,
render,
useCssVars,
createStaticVNode,
h,
reactive,
nextTick,
@@ -140,4 +141,26 @@ describe('useCssVars', () => {
expect((c as HTMLElement).style.getPropertyValue(`--color`)).toBe('red')
}
})
test('with createStaticVNode', async () => {
const state = reactive({ color: 'red' })
const root = document.createElement('div')
const App = {
setup() {
useCssVars(() => state)
return () => [
h('div'),
createStaticVNode('<div>1</div><div><span>2</span></div>', 2),
h('div')
]
}
}
render(h(App), root)
await nextTick()
for (const c of [].slice.call(root.children as any)) {
expect((c as HTMLElement).style.getPropertyValue(`--color`)).toBe('red')
}
})
})