postcss-nested 7.0.0 → 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 -23
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -74,34 +74,26 @@ function mergeSelectors(parent, child) {
|
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* Move a child and its preceding comment(s) to after "after"
|
|
77
|
-
* ! It is necessary to clarify the comment
|
|
78
77
|
*/
|
|
79
|
-
function breakOut(child,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
let prevNode = node.prev()
|
|
86
|
-
if (prevNode?.type !== 'comment') continue
|
|
78
|
+
function breakOut(child, currentNode) {
|
|
79
|
+
if (child.prev()?.type !== 'comment') {
|
|
80
|
+
currentNode.after(child)
|
|
81
|
+
return child
|
|
82
|
+
}
|
|
87
83
|
|
|
88
|
-
|
|
84
|
+
let prevNode = child.prev()
|
|
89
85
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
86
|
+
/* Checking that the comment "describes" the rule following. Like this:
|
|
87
|
+
/* comment about the rule below *\
|
|
88
|
+
.rule {}
|
|
89
|
+
*/
|
|
90
|
+
let regexp = /[*]\/ *\n.*{/
|
|
95
91
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
after.after(node).after(prevNode)
|
|
99
|
-
}
|
|
92
|
+
if (child.parent.toString().match(regexp)) {
|
|
93
|
+
currentNode.after(child).after(prevNode)
|
|
100
94
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (changeParent) {
|
|
104
|
-
after.after(child)
|
|
95
|
+
else {
|
|
96
|
+
currentNode.after(child)
|
|
105
97
|
}
|
|
106
98
|
|
|
107
99
|
return child
|