svelte-dnd-action 0.9.70 → 0.9.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1687,6 +1687,9 @@
1687
1687
  return item[SHADOW_ITEM_MARKER_PROPERTY_NAME] ? draggedElData : item;
1688
1688
  });
1689
1689
  function finalizeWithinZone() {
1690
+ // The original-element rAF loop may have re-armed observation during the settle animation.
1691
+ // Cancel again before dispatching events that can update or destroy drop zones.
1692
+ unWatchDraggedElement();
1690
1693
  unlockOriginDzMinDimensions();
1691
1694
  dispatchFinalizeEvent(shadowElDropZone, items, {
1692
1695
  trigger: isDraggedOutsideOfAnyDz ? TRIGGERS.DROPPED_OUTSIDE_OF_ANY : TRIGGERS.DROPPED_INTO_ZONE,
@@ -1953,11 +1956,10 @@
1953
1956
  originDropZoneRoot.appendChild(draggedEl);
1954
1957
  // We will keep the original dom node in the dom because touch events keep firing on it, we want to re-add it after the framework removes it
1955
1958
  function keepOriginalElementInDom() {
1956
- // if the drag was already finalized (cleanupPostDrop cleared draggedEl), this rAF loop
1957
- // must not re-arm the watcher: the original element might leave the DOM long after the
1958
- // drop (ex: its component unmounts), which would call watchDraggedElement() with an
1959
- // undefined draggedEl and crash inside observe() (getBoundingClientRect of undefined)
1960
- if (!draggedEl) return;
1959
+ // Once the drop starts finalizing, handleDrop has stopped observation and this loop
1960
+ // must not re-arm it during the settle animation. After cleanup, draggedEl is cleared
1961
+ // as an additional guard against the original element leaving the DOM much later.
1962
+ if (!draggedEl || finalizingPreviousDrag) return;
1961
1963
  if (!originalDragTarget.parentElement) {
1962
1964
  originalDragTarget.setAttribute(ORIGINAL_DRAGGED_ITEM_MARKER_ATTRIBUTE, true);
1963
1965
  originDropZoneRoot.appendChild(originalDragTarget);
package/dist/index.mjs CHANGED
@@ -1681,6 +1681,9 @@ function handleDrop$1() {
1681
1681
  return item[SHADOW_ITEM_MARKER_PROPERTY_NAME] ? draggedElData : item;
1682
1682
  });
1683
1683
  function finalizeWithinZone() {
1684
+ // The original-element rAF loop may have re-armed observation during the settle animation.
1685
+ // Cancel again before dispatching events that can update or destroy drop zones.
1686
+ unWatchDraggedElement();
1684
1687
  unlockOriginDzMinDimensions();
1685
1688
  dispatchFinalizeEvent(shadowElDropZone, items, {
1686
1689
  trigger: isDraggedOutsideOfAnyDz ? TRIGGERS.DROPPED_OUTSIDE_OF_ANY : TRIGGERS.DROPPED_INTO_ZONE,
@@ -1947,11 +1950,10 @@ function dndzone$2(node, options) {
1947
1950
  originDropZoneRoot.appendChild(draggedEl);
1948
1951
  // We will keep the original dom node in the dom because touch events keep firing on it, we want to re-add it after the framework removes it
1949
1952
  function keepOriginalElementInDom() {
1950
- // if the drag was already finalized (cleanupPostDrop cleared draggedEl), this rAF loop
1951
- // must not re-arm the watcher: the original element might leave the DOM long after the
1952
- // drop (ex: its component unmounts), which would call watchDraggedElement() with an
1953
- // undefined draggedEl and crash inside observe() (getBoundingClientRect of undefined)
1954
- if (!draggedEl) return;
1953
+ // Once the drop starts finalizing, handleDrop has stopped observation and this loop
1954
+ // must not re-arm it during the settle animation. After cleanup, draggedEl is cleared
1955
+ // as an additional guard against the original element leaving the DOM much later.
1956
+ if (!draggedEl || finalizingPreviousDrag) return;
1955
1957
  if (!originalDragTarget.parentElement) {
1956
1958
  originalDragTarget.setAttribute(ORIGINAL_DRAGGED_ITEM_MARKER_ATTRIBUTE, true);
1957
1959
  originDropZoneRoot.appendChild(originalDragTarget);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "svelte-dnd-action",
3
3
  "description": "*An awesome drag and drop library for Svelte 3 and 4 (not using the browser's built-in dnd, thanks god): Rich animations, nested containers, touch support and more *",
4
- "version": "0.9.70",
4
+ "version": "0.9.71",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/isaacHagoel/svelte-dnd-action.git"
@@ -268,6 +268,9 @@ function handleDrop() {
268
268
 
269
269
  items = items.map(item => (item[SHADOW_ITEM_MARKER_PROPERTY_NAME] ? draggedElData : item));
270
270
  function finalizeWithinZone() {
271
+ // The original-element rAF loop may have re-armed observation during the settle animation.
272
+ // Cancel again before dispatching events that can update or destroy drop zones.
273
+ unWatchDraggedElement();
271
274
  unlockOriginDzMinDimensions();
272
275
  dispatchFinalizeEvent(shadowElDropZone, items, {
273
276
  trigger: isDraggedOutsideOfAnyDz ? TRIGGERS.DROPPED_OUTSIDE_OF_ANY : TRIGGERS.DROPPED_INTO_ZONE,
@@ -511,11 +514,10 @@ export function dndzone(node, options) {
511
514
  originDropZoneRoot.appendChild(draggedEl);
512
515
  // We will keep the original dom node in the dom because touch events keep firing on it, we want to re-add it after the framework removes it
513
516
  function keepOriginalElementInDom() {
514
- // if the drag was already finalized (cleanupPostDrop cleared draggedEl), this rAF loop
515
- // must not re-arm the watcher: the original element might leave the DOM long after the
516
- // drop (ex: its component unmounts), which would call watchDraggedElement() with an
517
- // undefined draggedEl and crash inside observe() (getBoundingClientRect of undefined)
518
- if (!draggedEl) return;
517
+ // Once the drop starts finalizing, handleDrop has stopped observation and this loop
518
+ // must not re-arm it during the settle animation. After cleanup, draggedEl is cleared
519
+ // as an additional guard against the original element leaving the DOM much later.
520
+ if (!draggedEl || finalizingPreviousDrag) return;
519
521
  if (!originalDragTarget.parentElement) {
520
522
  originalDragTarget.setAttribute(ORIGINAL_DRAGGED_ITEM_MARKER_ATTRIBUTE, true);
521
523
  originDropZoneRoot.appendChild(originalDragTarget);