@@ -33,6 +33,9 @@ var Container = /*#__PURE__*/function (_Node) {
33
33
_proto . prepend = function prepend ( selector ) {
34
34
selector . parent = this ;
35
35
this . nodes . unshift ( selector ) ;
36
+ for ( var id in this . indexes ) {
37
+ this . indexes [ id ] ++ ;
38
+ }
36
39
return this ;
37
40
} ;
38
41
_proto . at = function at ( index ) {
@@ -69,29 +72,39 @@ var Container = /*#__PURE__*/function (_Node) {
69
72
return this . removeAll ( ) ;
70
73
} ;
71
74
_proto . insertAfter = function insertAfter ( oldNode , newNode ) {
75
+ var _this$nodes ;
72
76
newNode . parent = this ;
73
77
var oldIndex = this . index ( oldNode ) ;
74
- this . nodes . splice ( oldIndex + 1 , 0 , newNode ) ;
78
+ var resetNode = [ ] ;
79
+ for ( var i = 2 ; i < arguments . length ; i ++ ) {
80
+ resetNode . push ( arguments [ i ] ) ;
81
+ }
82
+ ( _this$nodes = this . nodes ) . splice . apply ( _this$nodes , [ oldIndex + 1 , 0 , newNode ] . concat ( resetNode ) ) ;
75
83
newNode . parent = this ;
76
84
var index ;
77
85
for ( var id in this . indexes ) {
78
86
index = this . indexes [ id ] ;
79
- if ( oldIndex <= index ) {
80
- this . indexes [ id ] = index + 1 ;
87
+ if ( oldIndex < index ) {
88
+ this . indexes [ id ] = index + arguments . length - 1 ;
81
89
}
82
90
}
83
91
return this ;
84
92
} ;
85
93
_proto . insertBefore = function insertBefore ( oldNode , newNode ) {
94
+ var _this$nodes2 ;
86
95
newNode . parent = this ;
87
96
var oldIndex = this . index ( oldNode ) ;
88
- this . nodes . splice ( oldIndex , 0 , newNode ) ;
97
+ var resetNode = [ ] ;
98
+ for ( var i = 2 ; i < arguments . length ; i ++ ) {
99
+ resetNode . push ( arguments [ i ] ) ;
100
+ }
101
+ ( _this$nodes2 = this . nodes ) . splice . apply ( _this$nodes2 , [ oldIndex , 0 , newNode ] . concat ( resetNode ) ) ;
89
102
newNode . parent = this ;
90
103
var index ;
91
104
for ( var id in this . indexes ) {
92
105
index = this . indexes [ id ] ;
93
- if ( index < = oldIndex ) {
94
- this . indexes [ id ] = index + 1 ;
106
+ if ( index > = oldIndex ) {
107
+ this . indexes [ id ] = index + arguments . length - 1 ;
95
108
}
96
109
}
97
110
return this ;
@@ -117,7 +130,7 @@ var Container = /*#__PURE__*/function (_Node) {
117
130
* Return the most specific node at the line and column number given.
118
131
* The source location is based on the original parsed location, locations aren't
119
132
* updated as selector nodes are mutated.
120
- *
133
+ *
121
134
* Note that this location is relative to the location of the first character
122
135
* of the selector, and not the location of the selector in the overall document
123
136
* when used in conjunction with postcss.
0 commit comments