@@ -78,15 +78,19 @@ export default class Container extends Node {
7878 insertAfter ( oldNode , newNode ) {
7979 newNode . parent = this ;
8080 let oldIndex = this . index ( oldNode ) ;
81- this . nodes . splice ( oldIndex + 1 , 0 , newNode ) ;
81+ const resetNode = [ ] ;
82+ for ( let i = 2 ; i < arguments . length ; i ++ ) {
83+ resetNode . push ( arguments [ i ] ) ;
84+ }
85+ this . nodes . splice ( oldIndex + 1 , 0 , newNode , ...resetNode ) ;
8286
8387 newNode . parent = this ;
8488
8589 let index ;
8690 for ( let id in this . indexes ) {
8791 index = this . indexes [ id ] ;
8892 if ( oldIndex < index ) {
89- this . indexes [ id ] = index + 1 ;
93+ this . indexes [ id ] = index + arguments . length - 1 ;
9094 }
9195 }
9296
@@ -96,15 +100,19 @@ export default class Container extends Node {
96100 insertBefore ( oldNode , newNode ) {
97101 newNode . parent = this ;
98102 let oldIndex = this . index ( oldNode ) ;
99- this . nodes . splice ( oldIndex , 0 , newNode ) ;
103+ const resetNode = [ ] ;
104+ for ( let i = 2 ; i < arguments . length ; i ++ ) {
105+ resetNode . push ( arguments [ i ] ) ;
106+ }
107+ this . nodes . splice ( oldIndex , 0 , newNode , ...resetNode ) ;
100108
101109 newNode . parent = this ;
102110
103111 let index ;
104112 for ( let id in this . indexes ) {
105113 index = this . indexes [ id ] ;
106114 if ( index >= oldIndex ) {
107- this . indexes [ id ] = index + 1 ;
115+ this . indexes [ id ] = index + arguments . length - 1 ;
108116 }
109117 }
110118
@@ -132,7 +140,7 @@ export default class Container extends Node {
132140 * Return the most specific node at the line and column number given.
133141 * The source location is based on the original parsed location, locations aren't
134142 * updated as selector nodes are mutated.
135- *
143+ *
136144 * Note that this location is relative to the location of the first character
137145 * of the selector, and not the location of the selector in the overall document
138146 * when used in conjunction with postcss.
0 commit comments