mirror of
https://github.com/thangisme/notes.git
synced 2024-11-01 03:27:29 -04: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)
|
|
}
|