|
|
@@ -264,25 +264,27 @@ this.matchedRules = this.matchedRules || (() => {
|
|
|
function getStylesInfo(elementInfo, stylesheet/*, element */) {
|
|
|
const stylesInfo = new Map();
|
|
|
elementInfo.forEach(selectorInfo => {
|
|
|
+ let declarations;
|
|
|
if (selectorInfo.styleInfo) {
|
|
|
- processDeclarations(selectorInfo.styleInfo.cssStyle.children, selectorInfo);
|
|
|
+ declarations = selectorInfo.styleInfo.cssStyle.children;
|
|
|
} else {
|
|
|
- processDeclarations(selectorInfo.ruleInfo.cssRule.block.children, selectorInfo);
|
|
|
+ declarations = selectorInfo.ruleInfo.cssRule.block.children;
|
|
|
}
|
|
|
+ processDeclarations(stylesInfo, declarations, selectorInfo, stylesheet);
|
|
|
});
|
|
|
return stylesInfo;
|
|
|
+ }
|
|
|
|
|
|
- function processDeclarations(declarations, selectorInfo) {
|
|
|
- const processedProperties = new Set();
|
|
|
- for (let declaration = declarations.tail; declaration; declaration = declaration.prev) {
|
|
|
- const declarationData = declaration.data;
|
|
|
- if (declarationData.type == "Declaration" && !processedProperties.has(declarationData.property) && !invalidDeclaration(cssTree.generate(declarationData), stylesheet)) {
|
|
|
- const styleValue = cssTree.generate(declarationData.value);
|
|
|
- const elementStyleInfo = stylesInfo.get(declarationData);
|
|
|
- if (styleValue.trim() && (!elementStyleInfo || (declarationData.important && !elementStyleInfo.important))) {
|
|
|
- stylesInfo.set(declarationData, { selectorInfo, styleValue, important: declarationData.important });
|
|
|
- processedProperties.add(declarationData.property);
|
|
|
- }
|
|
|
+ function processDeclarations(stylesInfo, declarations, selectorInfo, stylesheet) {
|
|
|
+ const processedProperties = new Set();
|
|
|
+ for (let declaration = declarations.tail; declaration; declaration = declaration.prev) {
|
|
|
+ const declarationData = declaration.data;
|
|
|
+ if (declarationData.type == "Declaration" && !processedProperties.has(declarationData.property) && !invalidDeclaration(cssTree.generate(declarationData), stylesheet)) {
|
|
|
+ const styleValue = cssTree.generate(declarationData.value);
|
|
|
+ const elementStyleInfo = stylesInfo.get(declarationData);
|
|
|
+ if (styleValue.trim() && (!elementStyleInfo || (declarationData.important && !elementStyleInfo.important))) {
|
|
|
+ stylesInfo.set(declarationData, { selectorInfo, styleValue, important: declarationData.important });
|
|
|
+ processedProperties.add(declarationData.property);
|
|
|
}
|
|
|
}
|
|
|
}
|