JSFiddle - React, Tailwind, and code Playground
JavaScript
var resolveAppliedStyle = (function () {
var documentElement = document.documentElement,
matchesSelector =
documentElement.matchesSelector ||
documentElement.mozMatchesSelector ||
documentElement.webkitMatchesSelector ||
documentElement.msMatchesSelector ||
documentElement.oMatchesSelector;
if (!matchesSelector) {
if (document.querySelectorAll) {
matchesSelector = function (selector) {
var matchingElements = this.parentNode.querySelectorAll(selector),
count = matchingElements.length;
for (var i = 0; i < count; ++i) {
if (matchingElements[i] === this) {
return true;
}
}
return false;
};
}
else {
throw new Error("no browser support for selector matching");
}
}
function styleImportanceByRule(rule, styleProperty) {
if (rule.style.getPropertyPriority) {
return rule.style.getPropertyPriority(styleProperty) === "important" ? 100000 : 0;
}
else {
return 0;
}
}
function styleImportanceByStyleText(styleText) {
return styleText.match(/\s!important/gi) ? 100000 : 0;
}
function resolveAppliedStyle(element, style) {
var styleSheets = document.styleSheets,
numberOfStyleSheets = styleSheets.length,
styleSheet,
styleSheetIndex,
rule,
rules,
numberOfRules,
ruleIndex,
appliedRule,
scoredStyles = [],
inlineStyle,
potentiallyAppliedStyle,
cssStyleSpecificityScore,
styleSpecificity,
matchesSelectorResult;
for (styleSheetIndex = 0; styleSheetIndex <...