From 747f80745d2a9c6f1673d736f82db5227338d117 Mon Sep 17 00:00:00 2001 From: Belinda Date: Wed, 16 Aug 2023 17:03:42 +0800 Subject: [PATCH] fix: filter out comment node to prevent sorting issue with collapsible table --- src/vuedraggable.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/vuedraggable.js b/src/vuedraggable.js index 84702206..ed99153d 100644 --- a/src/vuedraggable.js +++ b/src/vuedraggable.js @@ -11,7 +11,10 @@ function buildAttribute(object, propName, value) { } function computeVmIndex(vnodes, element) { - return vnodes.map(elt => elt.elm).indexOf(element); + return vnodes + .map(elt => elt.elm) + .filter(elt => elt.nodeName !== '#comment') + .indexOf(element); } function computeIndexes(slots, children, isTransition, footerOffset) { @@ -19,7 +22,7 @@ function computeIndexes(slots, children, isTransition, footerOffset) { return []; } - const elmFromNodes = slots.map(elt => elt.elm); + const elmFromNodes = slots.map(elt => elt.elm).filter(elt => elt.nodeName !== '#comment'); const footerIndex = children.length - footerOffset; const rawIndexes = [...children].map((elt, idx) => idx >= footerIndex ? elmFromNodes.length : elmFromNodes.indexOf(elt)