fix(sfc): fix style variables injection on static vnode (#3847)
fix #3841
This commit is contained in:
@@ -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')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user