Skip to content

Commit 7c72d43

Browse files
Adding logic to deal with transition with or without fragment
1 parent d436305 commit 7c72d43

File tree

2 files changed

+249
-237
lines changed

2 files changed

+249
-237
lines changed

src/vuedraggable.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,16 @@ const draggableComponent = defineComponent({
199199

200200
computed: {
201201
rootContainer() {
202-
return this.$el;
202+
const { $el, transitionMode } = this;
203+
if (!transitionMode) {
204+
return $el;
205+
}
206+
const {children} = $el;
207+
if (children.length !== 1) {
208+
return $el;
209+
}
210+
const firstChild = children.item(0);
211+
return firstChild.tagName !== "text" ? firstChild : $el;
203212
},
204213

205214
realList() {
@@ -250,8 +259,12 @@ const draggableComponent = defineComponent({
250259
}
251260
//const rawNodes = this.defaultSlots;
252261
if (transitionMode) {
262+
const [{ children }] = defaultSlots;
263+
if (Array.isArray(children)) {
264+
return children;
265+
}
253266
//TODO check transition with tag
254-
return [...this.$el.children]
267+
return [...this.rootContainer.children]
255268
.map(c => c.__vnode)
256269
.filter(node => !!node.transition);
257270
}

0 commit comments

Comments
 (0)