import type { SFCDescriptor } from '../parse'
import type { PluginCreator } from 'postcss'
import hash from 'hash-sum'
-import { capitalize, getEscapedCssVarName } from '@vue/shared'
+import { getEscapedCssVarName } from '@vue/shared'
export const CSS_VARS_HELPER = `useCssVars`
export function getCssVarsHelper(vapor: boolean | undefined): string {
- return vapor ? `vapor${capitalize(CSS_VARS_HELPER)}` : CSS_VARS_HELPER
+ return vapor ? `useVaporCssVars` : CSS_VARS_HELPER
}
export function genCssVarsFromList(
}
}
+/**
+ * @internal
+ * shared between vdom and vapor
+ */
export function baseUseCssVars(
instance: GenericComponentInstance | null,
getParentNode: () => Node,
/* v8 ignore stop */
if (__DEV__) {
- instance.getCssVars = () => getVars()
+ instance.getCssVars = getVars
}
const updateTeleports = (instance.ut = (vars = getVars()) => {
})
}
+/**
+ * @internal
+ * shared between vdom and vapor
+ */
export function setVarsOnNode(el: Node, vars: Record<string, string>): void {
if (el.nodeType === 1) {
const style = (el as HTMLElement).style
renderEffect,
setStyle,
template,
- vaporUseCssVars,
+ useVaporCssVars,
} from '@vue/runtime-vapor'
import { nextTick, onMounted, reactive, ref } from '@vue/runtime-core'
import { makeRender } from '../_utils'
const define = makeRender()
-describe('vaporUseCssVars', () => {
+describe('useVaporCssVars', () => {
async function assertCssVars(getApp: (state: any) => VaporComponent) {
const state = reactive({ color: 'red' })
const App = getApp(state)
const t0 = template('<div></div>')
await assertCssVars(state => ({
setup() {
- vaporUseCssVars(() => state)
+ useVaporCssVars(() => state)
const n0 = t0()
return n0
},
const t0 = template('<div></div>')
await assertCssVars(state => ({
setup() {
- vaporUseCssVars(() => state)
+ useVaporCssVars(() => state)
const n0 = t0()
const n1 = t0()
return [n0, n1]
})
await assertCssVars(state => ({
setup() {
- vaporUseCssVars(() => state)
+ useVaporCssVars(() => state)
return createComponent(Child)
},
}))
define({
setup() {
- vaporUseCssVars(() => state)
+ useVaporCssVars(() => state)
const n0 = createIf(
() => value.value,
() => {
const t0 = template('<div></div>')
define({
setup() {
- vaporUseCssVars(() => state)
+ useVaporCssVars(() => state)
return createComponent(Child, null, {
default: () => {
return createIf(
define({
setup() {
- vaporUseCssVars(() => state)
+ useVaporCssVars(() => state)
const n0 = t0() as any
renderEffect(() =>
setStyle(n0, state.color ? 'pointer-events: none' : undefined),
define({
setup() {
- vaporUseCssVars(() => state)
+ useVaporCssVars(() => state)
return createIf(
() => value.value,
() => createComponent(Child),
define({
setup() {
- vaporUseCssVars(() => state)
+ useVaporCssVars(() => state)
onMounted(() => {
colorInOnMount = (
root.children[0] as HTMLElement
import { isArray } from '@vue/shared'
import type { Block } from '../block'
-export function vaporUseCssVars(getter: () => Record<string, string>): void {
+export function useVaporCssVars(getter: () => Record<string, string>): void {
if (!__BROWSER__ && !__TEST__) return
-
const instance = currentInstance as VaporComponentInstance
baseUseCssVars(
instance,
() => resolveParentNode(instance.block),
- () => getter(),
+ getter,
vars => setVarsOnBlock(instance.block, vars),
)
}