postcss-nested 7.0.0 → 7.0.1
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 +9 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -74,34 +74,36 @@ 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,
|
|
78
|
+
function breakOut(child, parent) {
|
|
80
79
|
let changeParent = true
|
|
80
|
+
let lastNode = parent
|
|
81
81
|
|
|
82
|
-
for (let node of
|
|
82
|
+
for (let node of parent.nodes) {
|
|
83
83
|
if (!node.nodes) continue
|
|
84
84
|
|
|
85
85
|
let prevNode = node.prev()
|
|
86
86
|
if (prevNode?.type !== 'comment') continue
|
|
87
87
|
|
|
88
|
-
let parentRule =
|
|
88
|
+
let parentRule = parent.toString()
|
|
89
89
|
|
|
90
90
|
/* Checking that the comment "describes" the rule following. Like this:
|
|
91
91
|
/* comment about the rule below /*
|
|
92
92
|
.rule {}
|
|
93
93
|
*/
|
|
94
|
-
let regexp =
|
|
94
|
+
let regexp = /[*]\/ *\n.*{/
|
|
95
95
|
|
|
96
96
|
if (parentRule.match(regexp)) {
|
|
97
97
|
changeParent = false
|
|
98
|
-
|
|
98
|
+
lastNode.after(node).after(prevNode)
|
|
99
|
+
|
|
100
|
+
lastNode = node
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
// It is necessary if the above child has never been moved
|
|
103
105
|
if (changeParent) {
|
|
104
|
-
|
|
106
|
+
parent.after(child)
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
return child
|