UNPKG

@wordpress/block-library

Version:
21 lines (17 loc) 808 B
function getComputedStyle(node) { return node.ownerDocument.defaultView.getComputedStyle(node); } export function detectColors(colorsDetectionElement, setColor, setBackground) { if (!colorsDetectionElement) { return; } setColor(getComputedStyle(colorsDetectionElement).color); let backgroundColorNode = colorsDetectionElement; let backgroundColor = getComputedStyle(backgroundColorNode).backgroundColor; while (backgroundColor === 'rgba(0, 0, 0, 0)' && backgroundColorNode.parentNode && backgroundColorNode.parentNode.nodeType === backgroundColorNode.parentNode.ELEMENT_NODE) { backgroundColorNode = backgroundColorNode.parentNode; backgroundColor = getComputedStyle(backgroundColorNode).backgroundColor; } setBackground(backgroundColor); } //# sourceMappingURL=utils.js.map