(key: string, value: string)
| 787 | } |
| 788 | |
| 789 | function processValue(key: string, value: string) { |
| 790 | const protectedFragments = createProtectedFragments() |
| 791 | let current = value |
| 792 | const useDisplayMode = displayMode != null |
| 793 | |
| 794 | if (useDisplayMode) { |
| 795 | current = preprocessCssValue(current) |
| 796 | current = current.replace(ZERO_UNITS_RE, '$10').trim() |
| 797 | } else { |
| 798 | current = normalizeStyleValue(current) |
| 799 | } |
| 800 | |
| 801 | if (typeof scale === 'number' && scale !== 1) { |
| 802 | current = scalePxValue(current, scale) |
| 803 | } |
| 804 | |
| 805 | if (variableSyntaxMap.size || typeof transformVariable === 'function') { |
| 806 | current = replaceVarFunctions(current, ({ full, name, fallback }) => { |
| 807 | const syntax = getVariableSyntax(name) |
| 808 | if (syntax) { |
| 809 | return protectedFragments.protect(syntax) |
| 810 | } |
| 811 | |
| 812 | if (typeof transformVariable !== 'function') { |
| 813 | return full |
| 814 | } |
| 815 | |
| 816 | const trimmed = name.trim() |
| 817 | const normalizedName = trimmed.startsWith('--') ? trimmed.slice(2) : trimmed |
| 818 | return transformVariable({ |
| 819 | code: current, |
| 820 | name: normalizedName, |
| 821 | value: fallback, |
| 822 | options |
| 823 | }) |
| 824 | }) |
| 825 | } |
| 826 | |
| 827 | if (useDisplayMode) { |
| 828 | current = applyDisplayMode(current) |
| 829 | if (displayMode === 'resolved') { |
| 830 | current = simplifyColorMixToRgba(current) |
| 831 | } |
| 832 | } |
| 833 | |
| 834 | current = simplifyHexAlphaToRgba(current) |
| 835 | |
| 836 | if (KEEP_PX_PROPS.has(key)) { |
| 837 | return protectedFragments.restore(current) |
| 838 | } |
| 839 | |
| 840 | if (typeof transformPx === 'function') { |
| 841 | current = transformPxValue(current, (value) => transformPx({ value, options })) |
| 842 | } |
| 843 | |
| 844 | if (useRem) { |
| 845 | current = pxToRem(current, rootFontSize) |
| 846 | } |
no test coverage detected