mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-04-12 22:52:21 -06:00
22 lines
418 B
JavaScript
22 lines
418 B
JavaScript
/* @flow */
|
|
"use strict"
|
|
|
|
/**
|
|
* Find the at-rule in which a rule is nested.
|
|
*
|
|
* Returns `null` if the rule is not nested within an at-rule.
|
|
*/
|
|
module.exports = function findAtRuleContext(
|
|
rule/*: postcss$rule */
|
|
)/*: ?postcss$atRule*/ {
|
|
const parent = rule.parent
|
|
|
|
if (parent.type === "root") {
|
|
return null
|
|
}
|
|
if (parent.type === "atrule") {
|
|
return parent
|
|
}
|
|
return findAtRuleContext(parent)
|
|
}
|