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.

18 lines
644 B

4 years ago
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = sameParent;
  6. function sameParent(ruleA, ruleB) {
  7. let hasParent = ruleA.parent && ruleB.parent;
  8. // Check for detached rules
  9. if (!hasParent) {
  10. return true;
  11. }
  12. // If an at rule, ensure that the parameters are the same
  13. if (ruleA.parent.type === 'atrule' && ruleB.parent.type === 'atrule') {
  14. return ruleA.parent.params === ruleB.parent.params && ruleA.parent.name.toLowerCase() === ruleB.parent.name.toLowerCase();
  15. }
  16. return ruleA.parent.type === ruleB.parent.type;
  17. }
  18. module.exports = exports['default'];