This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const compareColor = (color, property) => (targetElement) => { | |
const tempElement = document.createElement('div'); | |
tempElement.style.color = color; | |
tempElement.style.display = 'none'; // make sure it doesn't actually render | |
document.body.appendChild(tempElement); // append so that `getComputedStyle` actually works | |
const tempColor = getComputedStyle(tempElement).color; | |
const targetColor = getComputedStyle(targetElement[0])[property]; | |
document.body.removeChild(tempElement); // remove it because we're done with it |
OlderNewer