el-beeswarm
Version:
<div style="display: flex; padding: 1rem; flex-direction: column; align-items: center; justify-content: center; height: 100vh; text-align: center; display: flex;
24 lines (19 loc) • 449 B
JavaScript
;
/**
* 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);
};