@wordpress/block-library
Version:
Block library for the WordPress editor.
21 lines (17 loc) • 808 B
JavaScript
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