You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
596 B

4 years ago
  1. var MODIFIER_PATTERN = /\-\-.+$/;
  2. function rulesOverlap(rule1, rule2, bemMode) {
  3. var scope1;
  4. var scope2;
  5. var i, l;
  6. var j, m;
  7. for (i = 0, l = rule1.length; i < l; i++) {
  8. scope1 = rule1[i][1];
  9. for (j = 0, m = rule2.length; j < m; j++) {
  10. scope2 = rule2[j][1];
  11. if (scope1 == scope2) {
  12. return true;
  13. }
  14. if (bemMode && withoutModifiers(scope1) == withoutModifiers(scope2)) {
  15. return true;
  16. }
  17. }
  18. }
  19. return false;
  20. }
  21. function withoutModifiers(scope) {
  22. return scope.replace(MODIFIER_PATTERN, '');
  23. }
  24. module.exports = rulesOverlap;