svelte-dnd-action 0.9.69 → 0.9.70

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
@@ -1953,6 +1953,11 @@
1953
1953
  originDropZoneRoot.appendChild(draggedEl);
1954
1954
  // 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
1955
  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;
1956
1961
  if (!originalDragTarget.parentElement) {
1957
1962
  originalDragTarget.setAttribute(ORIGINAL_DRAGGED_ITEM_MARKER_ATTRIBUTE, true);
1958
1963
  originDropZoneRoot.appendChild(originalDragTarget);
package/dist/index.mjs CHANGED
@@ -1947,6 +1947,11 @@ function dndzone$2(node, options) {
1947
1947
  originDropZoneRoot.appendChild(draggedEl);
1948
1948
  // 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
1949
  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;
1950
1955
  if (!originalDragTarget.parentElement) {
1951
1956
  originalDragTarget.setAttribute(ORIGINAL_DRAGGED_ITEM_MARKER_ATTRIBUTE, true);
1952
1957
  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.69",
4
+ "version": "0.9.70",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/isaacHagoel/svelte-dnd-action.git"
@@ -511,6 +511,11 @@ export function dndzone(node, options) {
511
511
  originDropZoneRoot.appendChild(draggedEl);
512
512
  // 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
513
  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;
514
519
  if (!originalDragTarget.parentElement) {
515
520
  originalDragTarget.setAttribute(ORIGINAL_DRAGGED_ITEM_MARKER_ATTRIBUTE, true);
516
521
  originDropZoneRoot.appendChild(originalDragTarget);