all files / popper/utils/ getBordersSize.js

100% Statements 3/3
100% Branches 4/4
100% Functions 1/1
100% Lines 3/3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16                    564× 564×   564×    
/*
 * Helper to detect borders of a given element
 * @method
 * @memberof Popper.Utils
 * @param {CSSStyleDeclaration} styles - result of `getStyleComputedProperty` on the given element
 * @param {String} axis - `x` or `y`
 * @return {Number} borders - the borders size of the given axis
 */
 
export default function getBordersSize(styles, axis) {
    const sideA = axis === 'x' ? 'Left' : 'Top';
    const sideB = sideA === 'Left' ? 'Right' : 'Bottom';
 
    return Number(styles[`border${sideA}Width`].split('px')[0]) + Number(styles[`border${sideB}Width`].split('px')[0]);
}