All files / shared/src cssVars.ts

100% Statements 17/17
100% Branches 13/13
100% Functions 1/1
100% Lines 17/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25        2x 73x 6x 6x   71x 60x 60x   73x 5x 5x 5x 5x 5x 5x 5x   7x 7x  
/**
 * Normalize CSS var value created by `v-bind` in `<style>` block
 * See https://github.com/vuejs/core/pull/12461#issuecomment-2495804664
 */
export function normalizeCssVarValue(value: unknown): string {
  if (value == null) {
    return 'initial'
  }
 
  if (typeof value === 'string') {
    return value === '' ? ' ' : value
  }
 
  if (typeof value !== 'number' || !Number.isFinite(value)) {
    if (__DEV__) {
      console.warn(
        '[Vue warn] Invalid value used for CSS binding. Expected a string or a finite number but received:',
        value,
      )
    }
  }
 
  return String(value)
}