diff --git a/src/Sortable.js b/src/Sortable.js index 7a8274d21..8df9be449 100644 --- a/src/Sortable.js +++ b/src/Sortable.js @@ -5,6 +5,8 @@ * @license MIT */ +import './windowCheck.js'; // Always import first + import { version } from '../package.json'; import { IE11OrLess, Edge, FireFox, Safari, IOS, ChromeForAndroid } from './BrowserInfo.js'; @@ -92,10 +94,6 @@ function _dispatchEvent(info) { } -if (typeof window === "undefined" || !window.document) { - throw new Error("Sortable.js requires a window with a document"); -} - let dragEl, parentEl, ghostEl, diff --git a/src/windowCheck.js b/src/windowCheck.js new file mode 100644 index 000000000..e6cf9e033 --- /dev/null +++ b/src/windowCheck.js @@ -0,0 +1,3 @@ +if (typeof window === "undefined" || !window.document) { + throw new Error("Sortable.js requires a window with a document"); +}