postcss-nested 7.0.1 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +15 -25
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -75,35 +75,25 @@ function mergeSelectors(parent, child) {
|
|
|
75
75
|
/**
|
|
76
76
|
* Move a child and its preceding comment(s) to after "after"
|
|
77
77
|
*/
|
|
78
|
-
function breakOut(child,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (!node.nodes) continue
|
|
84
|
-
|
|
85
|
-
let prevNode = node.prev()
|
|
86
|
-
if (prevNode?.type !== 'comment') continue
|
|
87
|
-
|
|
88
|
-
let parentRule = parent.toString()
|
|
78
|
+
function breakOut(child, currentNode) {
|
|
79
|
+
if (child.prev()?.type !== 'comment') {
|
|
80
|
+
currentNode.after(child)
|
|
81
|
+
return child
|
|
82
|
+
}
|
|
89
83
|
|
|
90
|
-
|
|
91
|
-
/* comment about the rule below /*
|
|
92
|
-
.rule {}
|
|
93
|
-
*/
|
|
94
|
-
let regexp = /[*]\/ *\n.*{/
|
|
84
|
+
let prevNode = child.prev()
|
|
95
85
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
86
|
+
/* Checking that the comment "describes" the rule following. Like this:
|
|
87
|
+
/* comment about the rule below *\
|
|
88
|
+
.rule {}
|
|
89
|
+
*/
|
|
90
|
+
let regexp = /[*]\/ *\n.*{/
|
|
99
91
|
|
|
100
|
-
|
|
101
|
-
|
|
92
|
+
if (child.parent.toString().match(regexp)) {
|
|
93
|
+
currentNode.after(child).after(prevNode)
|
|
102
94
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (changeParent) {
|
|
106
|
-
parent.after(child)
|
|
95
|
+
else {
|
|
96
|
+
currentNode.after(child)
|
|
107
97
|
}
|
|
108
98
|
|
|
109
99
|
return child
|