@@ -33,6 +33,9 @@ var Container = /*#__PURE__*/function (_Node) {
3333 _proto . prepend = function prepend ( selector ) {
3434 selector . parent = this ;
3535 this . nodes . unshift ( selector ) ;
36+ for ( var id in this . indexes ) {
37+ this . indexes [ id ] ++ ;
38+ }
3639 return this ;
3740 } ;
3841 _proto . at = function at ( index ) {
@@ -69,29 +72,39 @@ var Container = /*#__PURE__*/function (_Node) {
6972 return this . removeAll ( ) ;
7073 } ;
7174 _proto . insertAfter = function insertAfter ( oldNode , newNode ) {
75+ var _this$nodes ;
7276 newNode . parent = this ;
7377 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 ) ) ;
7583 newNode . parent = this ;
7684 var index ;
7785 for ( var id in this . indexes ) {
7886 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 ;
8189 }
8290 }
8391 return this ;
8492 } ;
8593 _proto . insertBefore = function insertBefore ( oldNode , newNode ) {
94+ var _this$nodes2 ;
8695 newNode . parent = this ;
8796 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 ) ) ;
89102 newNode . parent = this ;
90103 var index ;
91104 for ( var id in this . indexes ) {
92105 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 ;
95108 }
96109 }
97110 return this ;
@@ -117,7 +130,7 @@ var Container = /*#__PURE__*/function (_Node) {
117130 * Return the most specific node at the line and column number given.
118131 * The source location is based on the original parsed location, locations aren't
119132 * updated as selector nodes are mutated.
120- *
133+ *
121134 * Note that this location is relative to the location of the first character
122135 * of the selector, and not the location of the selector in the overall document
123136 * when used in conjunction with postcss.
0 commit comments