* convert max-width/max-height values that may be percentages into a number * @private
(styleValue: string | number, node: HTMLElement, parentProperty: string)
| 27 | */ |
| 28 | |
| 29 | function parseMaxStyle(styleValue: string | number, node: HTMLElement, parentProperty: string) { |
| 30 | let valueInPixels: number; |
| 31 | if (typeof styleValue === 'string') { |
| 32 | valueInPixels = parseInt(styleValue, 10); |
| 33 | |
| 34 | if (styleValue.indexOf('%') !== -1) { |
| 35 | // percentage * size in dimension |
| 36 | valueInPixels = (valueInPixels / 100) * node.parentNode[parentProperty]; |
| 37 | } |
| 38 | } else { |
| 39 | valueInPixels = styleValue; |
| 40 | } |
| 41 | |
| 42 | return valueInPixels; |
| 43 | } |
| 44 | |
| 45 | const getComputedStyle = (element: HTMLElement): CSSStyleDeclaration => |
| 46 | element.ownerDocument.defaultView.getComputedStyle(element, null); |
no outgoing calls
no test coverage detected