(element)
| 126 | } |
| 127 | |
| 128 | export function getEffectiveBackgroundColor(element) { |
| 129 | if (!element) { |
| 130 | // If no element provided or we have traversed beyond the body or html, |
| 131 | // we default to white as the background color. |
| 132 | return 'rgb(255, 255, 255)'; |
| 133 | } |
| 134 | |
| 135 | const style = window.getComputedStyle(element); |
| 136 | const bgColor = style.backgroundColor; |
| 137 | const hasBackgroundImage = style.backgroundImage !== 'none'; |
| 138 | const isTransparent = |
| 139 | bgColor === 'transparent' || bgColor === 'rgba(0, 0, 0, 0)'; |
| 140 | |
| 141 | if (!isTransparent || hasBackgroundImage) { |
| 142 | return bgColor; |
| 143 | } |
| 144 | |
| 145 | return getEffectiveBackgroundColor(element.parentElement); |
| 146 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…