This repository has been archived on 2020-11-02. You can view files and clone it, but cannot push or open issues or pull requests.
2020-11-01 22:46:04 +00:00

24 lines
449 B
JavaScript

'use strict';
/**
* Find the at-rule in which a rule is nested.
*
* Returns `null` if the rule is not nested within an at-rule.
*
* @param {import('postcss').Rule} rule
* @returns {null | import('postcss').AtRule}
*/
module.exports = function findAtRuleContext(rule) {
const parent = rule.parent;
if (parent.type === 'root') {
return null;
}
if (parent.type === 'atrule') {
return parent;
}
return findAtRuleContext(parent);
};