All files / src/render/dom/utils parse-dom-variant.ts

100% Statements 8/8
100% Branches 0/0
100% Functions 1/1
100% Lines 7/7

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 2034x   34x           34x           249x 249x 249x 249x    
import { resolveCSSVariables } from "./css-variables-conversion"
import { MakeTargetAnimatable } from "../../utils/animation"
import { unitConversion } from "./unit-conversion"
 
/**
 * Parse a DOM variant to make it animatable. This involves resolving CSS variables
 * and ensuring animations like "20%" => "calc(50vw)" are performed in pixels.
 */
export const parseDomVariant: MakeTargetAnimatable = (
    visualElement,
    target,
    origin,
    transitionEnd
) => {
    const resolved = resolveCSSVariables(visualElement, target, transitionEnd)
    target = resolved.target
    transitionEnd = resolved.transitionEnd
    return unitConversion(visualElement, target, origin, transitionEnd)
}