refactor: shorten scoped css var / animation prefix

This commit is contained in:
Evan You
2020-07-10 18:47:31 -04:00
parent 73807aeaf7
commit 5f271515cf
4 changed files with 35 additions and 29 deletions

View File

@@ -15,17 +15,21 @@ describe('useCssVars', () => {
const state = reactive({ color: 'red' })
const App = getApp(state)
const root = document.createElement('div')
const prefix = scopeId ? `${scopeId}-` : ``
const prefix = scopeId ? `${scopeId.replace(/^data-v-/, '')}-` : ``
render(h(App), root)
for (const c of [].slice.call(root.children as any)) {
expect((c as HTMLElement).style.getPropertyValue(`--${prefix}color`))
expect(
(c as HTMLElement).style.getPropertyValue(`--${prefix}color`)
).toBe(`red`)
}
state.color = 'green'
await nextTick()
for (const c of [].slice.call(root.children as any)) {
expect((c as HTMLElement).style.getPropertyValue(`--${prefix}color`))
expect(
(c as HTMLElement).style.getPropertyValue(`--${prefix}color`)
).toBe('green')
}
}
@@ -65,7 +69,7 @@ describe('useCssVars', () => {
})
test('with <style scoped>', async () => {
const id = 'v-12345'
const id = 'data-v-12345'
await assertCssVars(
state => ({