|
1 | 1 | /**! |
2 | | - * Sortable 1.10.0 |
| 2 | + * Sortable 1.10.1 |
3 | 3 | * @author RubaXa <trash@rubaxa.org> |
4 | 4 | * @author owenm <owen23355@gmail.com> |
5 | 5 | * @license MIT |
@@ -126,12 +126,14 @@ function _nonIterableSpread() { |
126 | 126 | throw new TypeError("Invalid attempt to spread non-iterable instance"); |
127 | 127 | } |
128 | 128 |
|
129 | | -var version = "1.10.0"; |
| 129 | +var version = "1.10.1"; |
130 | 130 |
|
131 | 131 | function userAgent(pattern) { |
132 | | - return !! |
133 | | - /*@__PURE__*/ |
134 | | - navigator.userAgent.match(pattern); |
| 132 | + if (typeof window !== 'undefined' && window.navigator) { |
| 133 | + return !! |
| 134 | + /*@__PURE__*/ |
| 135 | + navigator.userAgent.match(pattern); |
| 136 | + } |
135 | 137 | } |
136 | 138 |
|
137 | 139 | var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i); |
@@ -966,10 +968,6 @@ function _dispatchEvent(info) { |
966 | 968 | }, info)); |
967 | 969 | } |
968 | 970 |
|
969 | | -if (typeof window === "undefined" || !window.document) { |
970 | | - throw new Error("Sortable.js requires a window with a document"); |
971 | | -} |
972 | | - |
973 | 971 | var dragEl, |
974 | 972 | parentEl, |
975 | 973 | ghostEl, |
@@ -1007,12 +1005,14 @@ _silent = false, |
1007 | 1005 | savedInputChecked = []; |
1008 | 1006 | /** @const */ |
1009 | 1007 |
|
1010 | | -var PositionGhostAbsolutely = IOS, |
| 1008 | +var documentExists = typeof document !== 'undefined', |
| 1009 | + PositionGhostAbsolutely = IOS, |
1011 | 1010 | CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float', |
1012 | 1011 | // This will not pass for IE9, because IE9 DnD only works on anchors |
1013 | | -supportDraggable = !ChromeForAndroid && !IOS && 'draggable' in document.createElement('div'), |
| 1012 | +supportDraggable = documentExists && !ChromeForAndroid && !IOS && 'draggable' in document.createElement('div'), |
1014 | 1013 | supportCssPointerEvents = function () { |
1015 | | - // false when <= IE11 |
| 1014 | + if (!documentExists) return; // false when <= IE11 |
| 1015 | + |
1016 | 1016 | if (IE11OrLess) { |
1017 | 1017 | return false; |
1018 | 1018 | } |
@@ -1126,15 +1126,17 @@ _detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) { |
1126 | 1126 | }; // #1184 fix - Prevent click event on fallback if dragged but item not changed position |
1127 | 1127 |
|
1128 | 1128 |
|
1129 | | -document.addEventListener('click', function (evt) { |
1130 | | - if (ignoreNextClick) { |
1131 | | - evt.preventDefault(); |
1132 | | - evt.stopPropagation && evt.stopPropagation(); |
1133 | | - evt.stopImmediatePropagation && evt.stopImmediatePropagation(); |
1134 | | - ignoreNextClick = false; |
1135 | | - return false; |
1136 | | - } |
1137 | | -}, true); |
| 1129 | +if (documentExists) { |
| 1130 | + document.addEventListener('click', function (evt) { |
| 1131 | + if (ignoreNextClick) { |
| 1132 | + evt.preventDefault(); |
| 1133 | + evt.stopPropagation && evt.stopPropagation(); |
| 1134 | + evt.stopImmediatePropagation && evt.stopImmediatePropagation(); |
| 1135 | + ignoreNextClick = false; |
| 1136 | + return false; |
| 1137 | + } |
| 1138 | + }, true); |
| 1139 | +} |
1138 | 1140 |
|
1139 | 1141 | var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) { |
1140 | 1142 | if (dragEl) { |
@@ -2594,11 +2596,14 @@ function _cancelNextTick(id) { |
2594 | 2596 | } // Fixed #973: |
2595 | 2597 |
|
2596 | 2598 |
|
2597 | | -on(document, 'touchmove', function (evt) { |
2598 | | - if ((Sortable.active || awaitingDragStarted) && evt.cancelable) { |
2599 | | - evt.preventDefault(); |
2600 | | - } |
2601 | | -}); // Export utils |
| 2599 | +if (documentExists) { |
| 2600 | + on(document, 'touchmove', function (evt) { |
| 2601 | + if ((Sortable.active || awaitingDragStarted) && evt.cancelable) { |
| 2602 | + evt.preventDefault(); |
| 2603 | + } |
| 2604 | + }); |
| 2605 | +} // Export utils |
| 2606 | + |
2602 | 2607 |
|
2603 | 2608 | Sortable.utils = { |
2604 | 2609 | on: on, |
@@ -2900,6 +2905,7 @@ var drop = function drop(_ref) { |
2900 | 2905 | dispatchSortableEvent = _ref.dispatchSortableEvent, |
2901 | 2906 | hideGhostForTarget = _ref.hideGhostForTarget, |
2902 | 2907 | unhideGhostForTarget = _ref.unhideGhostForTarget; |
| 2908 | + if (!originalEvent) return; |
2903 | 2909 | var toSortable = putSortable || activeSortable; |
2904 | 2910 | hideGhostForTarget(); |
2905 | 2911 | var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent; |
|
0 commit comments