UNPKG

347 BJavaScriptView Raw
1module.exports = function getContainingNode(node) {
2 // For styled-components declarations are children of Root node
3 if (
4 node.type !== 'rule' &&
5 node.type !== 'atrule' &&
6 node.parent.document &&
7 node.parent.document.nodes &&
8 node.parent.document.nodes.some(item => item.type === 'root')
9 ) {
10 return node.parent;
11 }
12
13 return node;
14};