mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-06 20:11:38 +08:00
R=jacktfranklin@chromium.org Bug: 1213034 Change-Id: I5da8225f60b53870a1c67d6b5d02a464c08f4eb2 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2917088 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
35 lines
806 B
JavaScript
35 lines
806 B
JavaScript
var specificity = require('./specificity');
|
|
|
|
function specificitiesOverlap(selector1, selector2, cache) {
|
|
var specificity1;
|
|
var specificity2;
|
|
var i, l;
|
|
var j, m;
|
|
|
|
for (i = 0, l = selector1.length; i < l; i++) {
|
|
specificity1 = findSpecificity(selector1[i][1], cache);
|
|
|
|
for (j = 0, m = selector2.length; j < m; j++) {
|
|
specificity2 = findSpecificity(selector2[j][1], cache);
|
|
|
|
if (specificity1[0] === specificity2[0] && specificity1[1] === specificity2[1] && specificity1[2] === specificity2[2]) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
function findSpecificity(selector, cache) {
|
|
var value;
|
|
|
|
if (!(selector in cache)) {
|
|
cache[selector] = value = specificity(selector);
|
|
}
|
|
|
|
return value || cache[selector];
|
|
}
|
|
|
|
module.exports = specificitiesOverlap;
|