|
5 | 5 | * @license MIT
|
6 | 6 | */
|
7 | 7 |
|
8 |
| -import './windowCheck.js'; // Always import first |
9 |
| - |
10 | 8 | import { version } from '../package.json';
|
11 | 9 |
|
12 | 10 | import { IE11OrLess, Edge, FireFox, Safari, IOS, ChromeForAndroid } from './BrowserInfo.js';
|
@@ -140,14 +138,17 @@ let dragEl,
|
140 | 138 | savedInputChecked = [];
|
141 | 139 |
|
142 | 140 | /** @const */
|
143 |
| - const PositionGhostAbsolutely = IOS, |
| 141 | + const documentExists = typeof document !== 'undefined', |
| 142 | + |
| 143 | + PositionGhostAbsolutely = IOS, |
144 | 144 |
|
145 | 145 | CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float',
|
146 | 146 |
|
147 | 147 | // This will not pass for IE9, because IE9 DnD only works on anchors
|
148 |
| - supportDraggable = !ChromeForAndroid && !IOS && ('draggable' in document.createElement('div')), |
| 148 | + supportDraggable = documentExists && !ChromeForAndroid && !IOS && ('draggable' in document.createElement('div')), |
149 | 149 |
|
150 | 150 | supportCssPointerEvents = (function() {
|
| 151 | + if (!documentExists) return; |
151 | 152 | // false when <= IE11
|
152 | 153 | if (IE11OrLess) {
|
153 | 154 | return false;
|
@@ -297,15 +298,17 @@ let dragEl,
|
297 | 298 |
|
298 | 299 |
|
299 | 300 | // #1184 fix - Prevent click event on fallback if dragged but item not changed position
|
300 |
| -document.addEventListener('click', function(evt) { |
301 |
| - if (ignoreNextClick) { |
302 |
| - evt.preventDefault(); |
303 |
| - evt.stopPropagation && evt.stopPropagation(); |
304 |
| - evt.stopImmediatePropagation && evt.stopImmediatePropagation(); |
305 |
| - ignoreNextClick = false; |
306 |
| - return false; |
307 |
| - } |
308 |
| -}, true); |
| 301 | +if (documentExists) { |
| 302 | + document.addEventListener('click', function(evt) { |
| 303 | + if (ignoreNextClick) { |
| 304 | + evt.preventDefault(); |
| 305 | + evt.stopPropagation && evt.stopPropagation(); |
| 306 | + evt.stopImmediatePropagation && evt.stopImmediatePropagation(); |
| 307 | + ignoreNextClick = false; |
| 308 | + return false; |
| 309 | + } |
| 310 | + }, true); |
| 311 | +} |
309 | 312 |
|
310 | 313 | let nearestEmptyInsertDetectEvent = function(evt) {
|
311 | 314 | if (dragEl) {
|
@@ -1613,7 +1616,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
|
1613 | 1616 | return options[name];
|
1614 | 1617 | } else {
|
1615 | 1618 | let modifiedValue = PluginManager.modifyOption(this, name, value);
|
1616 |
| - if (typeof(modifiedValue) !== 'undefined') { |
| 1619 | + if (typeof modifiedValue !== 'undefined') { |
1617 | 1620 | options[name] = modifiedValue;
|
1618 | 1621 | } else {
|
1619 | 1622 | options[name] = value;
|
@@ -1884,11 +1887,13 @@ function _cancelNextTick(id) {
|
1884 | 1887 | }
|
1885 | 1888 |
|
1886 | 1889 | // Fixed #973:
|
1887 |
| -on(document, 'touchmove', function(evt) { |
1888 |
| - if ((Sortable.active || awaitingDragStarted) && evt.cancelable) { |
1889 |
| - evt.preventDefault(); |
1890 |
| - } |
1891 |
| -}); |
| 1890 | +if (documentExists) { |
| 1891 | + on(document, 'touchmove', function(evt) { |
| 1892 | + if ((Sortable.active || awaitingDragStarted) && evt.cancelable) { |
| 1893 | + evt.preventDefault(); |
| 1894 | + } |
| 1895 | + }); |
| 1896 | +} |
1892 | 1897 |
|
1893 | 1898 |
|
1894 | 1899 | // Export utils
|
|
0 commit comments