wip: new cssVars SSR integration + fix cssVars SSR injection for suspense
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
import { ssrResolveCssVars } from '../src'
|
||||
|
||||
describe('ssr: resolveCssVars', () => {
|
||||
test('should work', () => {
|
||||
expect(ssrResolveCssVars({ color: 'red' })).toMatchObject({
|
||||
style: {
|
||||
'--color': 'red'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
test('should work with scopeId', () => {
|
||||
expect(ssrResolveCssVars({ color: 'red' }, 'scoped')).toMatchObject({
|
||||
style: {
|
||||
'--scoped-color': 'red'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
test('should strip data-v prefix', () => {
|
||||
expect(ssrResolveCssVars({ color: 'red' }, 'data-v-123456')).toMatchObject({
|
||||
style: {
|
||||
'--123456-color': 'red'
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,11 +0,0 @@
|
||||
export function ssrResolveCssVars(
|
||||
source: Record<string, string>,
|
||||
scopeId?: string
|
||||
) {
|
||||
const style: Record<string, string> = {}
|
||||
const prefix = scopeId ? `${scopeId.replace(/^data-v-/, '')}-` : ``
|
||||
for (const key in source) {
|
||||
style[`--${prefix}${key}`] = source[key]
|
||||
}
|
||||
return { style }
|
||||
}
|
||||
@@ -18,7 +18,6 @@ export {
|
||||
export { ssrInterpolate } from './helpers/ssrInterpolate'
|
||||
export { ssrRenderList } from './helpers/ssrRenderList'
|
||||
export { ssrRenderSuspense } from './helpers/ssrRenderSuspense'
|
||||
export { ssrResolveCssVars } from './helpers/ssrResolveCssVars'
|
||||
|
||||
// v-model helpers
|
||||
export {
|
||||
|
||||
Reference in New Issue
Block a user