Skip to content

Commit 227b8a5

Browse files
corner case: fix for issue #167
1 parent be1593b commit 227b8a5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/vuedraggable.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,12 @@
174174
},
175175

176176
getUnderlyingVm(htmlElt) {
177-
const index = computeVmIndex(this.getChildrenNodes(), htmlElt)
177+
const index = computeVmIndex(this.getChildrenNodes() || [], htmlElt)
178+
if (index === -1) {
179+
//Edge case during move callback: related element might be
180+
//an element different from collection
181+
return null
182+
}
178183
const element = this.realList[index]
179184
return { index, element }
180185
},
@@ -222,7 +227,9 @@
222227
const context = { list, component }
223228
if (to !== related && list && component.getUnderlyingVm) {
224229
const destination = component.getUnderlyingVm(related)
225-
return Object.assign(destination, context)
230+
if (destination) {
231+
return Object.assign(destination, context)
232+
}
226233
}
227234

228235
return context

0 commit comments

Comments
 (0)