Bug 1085119 - Fixed wrong computed best matched style rule in DevTools
MozReview-Commit-ID: 2HYcMiRvhnP
--- a/devtools/server/css-logic.js
+++ b/devtools/server/css-logic.js
@@ -1224,20 +1224,30 @@ CssPropertyInfo.prototype = {
if (selectorInfo1.status > selectorInfo2.status) {
return -1;
} else if (selectorInfo2.status > selectorInfo1.status) {
return 1;
}
return selectorInfo1.compareTo(selectorInfo2);
});
- // Now we know which of the matches is best, we can mark it BEST_MATCH.
- if (this._matchedSelectors.length > 0 &&
- this._matchedSelectors[0].status > STATUS.UNMATCHED) {
- this._matchedSelectors[0].status = STATUS.BEST;
+ // Find which match is the best
+ if (this._matchedSelectors.length > 0) {
+ if (this._matchedSelectors[0].status > STATUS.UNMATCHED) {
+ let bestStatus = this._matchedSelectors[0].status;
+ let bestIndex = 0;
+
+ while (bestIndex + 1 < this._matchedSelectors.length &&
+ this._matchedSelectors[bestIndex + 1].status == bestStatus) {
+ bestIndex++;
+ }
+
+ // Now we know which of the matches is best, we can mark it BEST_MATCH.
+ this._matchedSelectors[bestStatus].status = STATUS.BEST;
+ }
}
},
/**
* Process a matched CssSelector object.
*
* @private
* @param {CssSelector} selector the matched CssSelector object.