@@ -36,7 +36,8 @@ import {
3636 clone ,
3737 expando ,
3838 getChildContainingRectFromElement ,
39- getParentOrHost
39+ getParentOrHost ,
40+ insertOrMoveBefore
4041} from './utils.js' ;
4142
4243
@@ -957,7 +958,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
957958 if ( Sortable . eventCanceled ) return ;
958959
959960 if ( ! _this . options . removeCloneOnHide ) {
960- rootEl . insertBefore ( cloneEl , dragEl ) ;
961+ insertOrMoveBefore ( rootEl , cloneEl , dragEl ) ;
961962 }
962963 _this . _hideClone ( ) ;
963964
@@ -1176,7 +1177,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
11761177
11771178 if ( ! Sortable . eventCanceled ) {
11781179 if ( nextEl ) {
1179- rootEl . insertBefore ( dragEl , nextEl ) ;
1180+ insertOrMoveBefore ( rootEl , dragEl , nextEl ) ;
11801181 } else {
11811182 rootEl . appendChild ( dragEl ) ;
11821183 }
@@ -1207,7 +1208,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
12071208 if ( onMove ( rootEl , el , dragEl , dragRect , target , targetRect , evt , ! ! target ) !== false ) {
12081209 capture ( ) ;
12091210 if ( elLastChild && elLastChild . nextSibling ) { // the last draggable element is not the last node
1210- el . insertBefore ( dragEl , elLastChild . nextSibling ) ;
1211+ insertOrMoveBefore ( el , dragEl , elLastChild . nextSibling ) ;
12111212 }
12121213 else {
12131214 el . appendChild ( dragEl ) ;
@@ -1229,7 +1230,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
12291230
12301231 if ( onMove ( rootEl , el , dragEl , dragRect , target , targetRect , evt , false ) !== false ) {
12311232 capture ( ) ;
1232- el . insertBefore ( dragEl , firstChild ) ;
1233+ insertOrMoveBefore ( el , dragEl , firstChild ) ;
12331234 parentEl = el ; // actualization
12341235
12351236 changed ( ) ;
@@ -1304,7 +1305,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
13041305 if ( after && ! nextSibling ) {
13051306 el . appendChild ( dragEl ) ;
13061307 } else {
1307- target . parentNode . insertBefore ( dragEl , after ? nextSibling : target ) ;
1308+ insertOrMoveBefore ( target . parentNode , dragEl , after ? nextSibling : target ) ;
13081309 }
13091310
13101311 // Undo chrome's scroll adjustment (has no effect on other browsers)
@@ -1742,9 +1743,9 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
17421743
17431744 // show clone at dragEl or original position
17441745 if ( dragEl . parentNode == rootEl && ! this . options . group . revertClone ) {
1745- rootEl . insertBefore ( cloneEl , dragEl ) ;
1746+ insertOrMoveBefore ( rootEl , cloneEl , dragEl ) ;
17461747 } else if ( nextEl ) {
1747- rootEl . insertBefore ( cloneEl , nextEl ) ;
1748+ insertOrMoveBefore ( rootEl , cloneEl , nextEl ) ;
17481749 } else {
17491750 rootEl . appendChild ( cloneEl ) ;
17501751 }
0 commit comments