Parcourir la source

deal with common issue when used with Sortable (fix #2145)

Evan You il y a 10 ans
Parent
commit
6993cfcdc5
1 fichiers modifiés avec 7 ajouts et 0 suppressions
  1. 7 0
      src/directives/public/for.js

+ 7 - 0
src/directives/public/for.js

@@ -358,6 +358,13 @@ const vFor = {
    */
    */
 
 
   move: function (frag, prevEl) {
   move: function (frag, prevEl) {
+    // fix a common issue with Sortable:
+    // if prevEl doesn't have nextSibling, this means it's
+    // been dragged after the end anchor. Just re-position
+    // the end anchor to the end of the container.
+    if (!prevEl.nextSibling) {
+      this.end.parentNode.appendChild(this.end)
+    }
     frag.before(prevEl.nextSibling, false)
     frag.before(prevEl.nextSibling, false)
   },
   },