Skip to content

Commit f494e3d

Browse files
committed
document un-nesting
1 parent 81e6e5a commit f494e3d

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function getExtendingRules(selectorIdMatch, extendAtRule) {
9696
// matching rule’s cloned nodes
9797
const nestingNodes = matchingRule.clone().nodes;
9898

99-
let parent = matchingRule.parent;
99+
// clone the matching rule as a nested rule
100100
let clone = extendAtRule.clone({
101101
name: 'nest',
102102
params: nestingSelectors,
@@ -105,16 +105,17 @@ function getExtendingRules(selectorIdMatch, extendAtRule) {
105105
raws: {}
106106
});
107107

108+
// preserve nesting of parent rules and at-rules
109+
let parent = matchingRule.parent;
110+
108111
while (parent && (parent.type === 'rule' || parent.type === 'atrule')) {
109112
clone = parent.clone().removeAll().append([ clone ]);
110113

111114
parent = parent.parent;
112115
}
113116

114117
// push the matching rule to the extending rules
115-
extendingRules.push(
116-
clone
117-
);
118+
extendingRules.push(clone);
118119
});
119120

120121
// return the extending rules

0 commit comments

Comments
 (0)