index.js 644 B

12345678910111213141516171819
  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'];