All files / app/common/dom getAppliedStyles.ts

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 14150x   150x       5x   9x          
import { kebabCase } from 'lodash';
 
export default function getAppliedStyles(
    element: HTMLElement,
    properties: string[]
): { [key: string]: string } {
    const declaration = window.getComputedStyle(element);
 
    return properties.reduce((result, propertyName) => ({
        ...result,
        [propertyName]: declaration.getPropertyValue(kebabCase(propertyName)),
    }), {});
}