11'use strict' ;
22
3- var _typeof = typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ? function ( obj ) { return typeof obj ; } : function ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ;
4-
53( function ( ) {
64 "use strict" ;
75
@@ -31,6 +29,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
3129 }
3230
3331 function _computeIndexes ( slots , children ) {
32+ if ( ! slots ) {
33+ return [ ] ;
34+ }
3435 return Array . prototype . map . call ( children , function ( elt ) {
3536 return computeVmIndex ( slots , elt ) ;
3637 } ) ;
@@ -81,7 +82,18 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
8182 var draggableComponent = {
8283 props : props ,
8384
85+ data : function data ( ) {
86+ return {
87+ transitionMode : false
88+ } ;
89+ } ,
8490 render : function render ( h ) {
91+ if ( this . $slots . default . length === 1 ) {
92+ var child = this . $slots . default [ 0 ] ;
93+ if ( child . componentOptions && child . componentOptions . tag === "transition-group" ) {
94+ this . transitionMode = true ;
95+ }
96+ }
8597 return h ( this . element , null , this . $slots . default ) ;
8698 } ,
8799 mounted : function mounted ( ) {
@@ -97,7 +109,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
97109 } ) ;
98110
99111 var options = merge ( this . options , optionsAdded ) ;
100- this . _sortable = new Sortable ( this . $el , options ) ;
112+ this . _sortable = new Sortable ( this . rootContainer , options ) ;
101113 this . computeIndexes ( ) ;
102114 } ,
103115 beforeDestroy : function beforeDestroy ( ) {
@@ -108,19 +120,29 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
108120 } ,
109121
110122
123+ computed : {
124+ rootContainer : function rootContainer ( ) {
125+ return this . transitionMode ? this . $el . children [ 0 ] : this . $el ;
126+ }
127+ } ,
128+
111129 methods : {
130+ getChildrenNodes : function getChildrenNodes ( ) {
131+ var rawNodes = this . $slots . default ;
132+ return this . transitionMode ? rawNodes [ 0 ] . child . $slots . default : rawNodes ;
133+ } ,
112134 computeIndexes : function computeIndexes ( ) {
113135 var _this3 = this ;
114136
115137 this . $nextTick ( function ( ) {
116- _this3 . visibleIndexes = _computeIndexes ( _this3 . $slots . default , _this3 . $el . children ) ;
138+ _this3 . visibleIndexes = _computeIndexes ( _this3 . getChildrenNodes ( ) , _this3 . rootContainer . children ) ;
117139 } ) ;
118140 } ,
119141 onDragStart : function onDragStart ( evt ) {
120142 if ( ! this . list ) {
121143 return ;
122144 }
123- var currentIndex = computeVmIndex ( this . $slots . default , evt . item ) ;
145+ var currentIndex = computeVmIndex ( this . getChildrenNodes ( ) , evt . item ) ;
124146 var element = this . list [ currentIndex ] ;
125147 this . context = {
126148 currentIndex : currentIndex ,
@@ -145,7 +167,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
145167 if ( ! this . list ) {
146168 return ;
147169 }
148- insertNodeAt ( this . $el , evt . item , evt . oldIndex ) ;
170+ insertNodeAt ( this . rootContainer , evt . item , evt . oldIndex ) ;
149171 var isCloning = ! ! evt . clone ;
150172 if ( isCloning ) {
151173 removeNode ( evt . clone ) ;
@@ -169,7 +191,6 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
169191 }
170192 }
171193 } ;
172-
173194 return draggableComponent ;
174195 }
175196
0 commit comments