File tree Expand file tree Collapse file tree 2 files changed +18
-22
lines changed Expand file tree Collapse file tree 2 files changed +18
-22
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,10 @@ class ComponentStructure {
4040 this . _checkCoherence ( ) ;
4141 }
4242
43+ get _domChildrenFromNodes ( ) {
44+ return this . _getChildrenNodes ( ) . map ( getHtmlElementFromNode ) ;
45+ }
46+
4347 _checkCoherence ( ) {
4448 if ( this . noneFunctional && this . transitionMode ) {
4549 throw new Error (
@@ -48,7 +52,7 @@ class ComponentStructure {
4852 }
4953 }
5054
51- getChildrenNodes ( ) {
55+ _getChildrenNodes ( ) {
5256 const {
5357 noneFunctional,
5458 transitionMode,
@@ -77,19 +81,17 @@ class ComponentStructure {
7781
7882 computeIndexes ( ) {
7983 const {
84+ _domChildrenFromNodes,
8085 transitionMode,
8186 offsets : { footer : footerOffset }
8287 } = this ;
8388
84- const domChildrenFromNodes = this . getChildrenNodes ( ) . map (
85- getHtmlElementFromNode
86- ) ;
8789 const domChildren = this . rootContainer . children ;
8890 const footerIndex = domChildren . length - footerOffset ;
8991 const rawIndexes = [ ...domChildren ] . map ( ( elt , idx ) =>
9092 idx >= footerIndex
91- ? domChildrenFromNodes . length
92- : domChildrenFromNodes . indexOf ( elt )
93+ ? _domChildrenFromNodes . length
94+ : _domChildrenFromNodes . indexOf ( elt )
9395 ) ;
9496 return transitionMode ? rawIndexes . filter ( ind => ind !== - 1 ) : rawIndexes ;
9597 }
@@ -102,6 +104,10 @@ class ComponentStructure {
102104 this . rootContainer = getRootContainer ( this ) ;
103105 return this ;
104106 }
107+
108+ computeVmIndex ( htmlElement ) {
109+ return this . _domChildrenFromNodes . indexOf ( htmlElement ) ;
110+ }
105111}
106112
107113export { ComponentStructure } ;
Original file line number Diff line number Diff line change @@ -9,18 +9,6 @@ import {
99import { computeComponentStructure } from "./core/renderHelper" ;
1010import { h , defineComponent , nextTick } from "vue" ;
1111
12- function computeVmIndex ( vNodes , htmlElement ) {
13- const domElements = vNodes . map ( ( { el } ) => el ) ;
14- const index = domElements . indexOf ( htmlElement ) ;
15- if ( index === - 1 ) {
16- throw new Error ( "node not found" , {
17- nodes : domElements ,
18- htmlElement
19- } ) ;
20- }
21- return index ;
22- }
23-
2412function emit ( evtName , evtData ) {
2513 nextTick ( ( ) => this . $emit ( evtName . toLowerCase ( ) , evtData ) ) ;
2614}
@@ -136,8 +124,11 @@ const draggableComponent = defineComponent({
136124 deep : true
137125 } ,
138126
139- realList ( ) {
140- this . computeIndexes ( ) ;
127+ realList : {
128+ handler ( ) {
129+ this . computeIndexes ( ) ;
130+ } ,
131+ deep : true
141132 }
142133 } ,
143134
@@ -156,8 +147,7 @@ const draggableComponent = defineComponent({
156147 } ,
157148
158149 getUnderlyingVm ( htmlElement ) {
159- const childrenNodes = this . componentStructure . getChildrenNodes ( ) ;
160- const index = computeVmIndex ( childrenNodes , htmlElement ) ;
150+ const index = this . componentStructure . computeVmIndex ( htmlElement ) ;
161151 if ( index === - 1 ) {
162152 //Edge case during move callback: related element might be
163153 //an element different from collection
You can’t perform that action at this time.
0 commit comments