From 0169c7510dbb350069610522768234590c887873 Mon Sep 17 00:00:00 2001 From: "e.fattal" Date: Fri, 14 Jun 2019 14:36:40 +0200 Subject: [PATCH] Fix https://github.com/SortableJS/Sortable/issues/1539 (when Array.prototype is modified) --- src/Sortable.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/Sortable.js b/src/Sortable.js index 723350b53..f2f3e43c3 100644 --- a/src/Sortable.js +++ b/src/Sortable.js @@ -223,18 +223,18 @@ let dragEl, * @return {HTMLElement} Element of the first found nearest Sortable */ _detectNearestEmptySortable = function(x, y) { - for (let i in sortables) { - if (lastChild(sortables[i])) continue; - - let rect = getRect(sortables[i]), - threshold = sortables[i][expando].options.emptyInsertThreshold, - insideHorizontally = x >= (rect.left - threshold) && x <= (rect.right + threshold), - insideVertically = y >= (rect.top - threshold) && y <= (rect.bottom + threshold); - - if (threshold && insideHorizontally && insideVertically) { - return sortables[i]; + return sortables.find(sortable => { + if (!lastChild(sortable)) { + let rect = getRect(sortable), + threshold = sortables[i][expando].options.emptyInsertThreshold, + insideHorizontally = x >= (rect.left - threshold) && x <= (rect.right + threshold), + insideVertically = y >= (rect.top - threshold) && y <= (rect.bottom + threshold); + + if (threshold && insideHorizontally && insideVertically) { + return true; + } } - } + }); }, _prepareGroup = function (options) { @@ -1883,15 +1883,14 @@ Sortable.utils = { Sortable.mount = function(...plugins) { if (plugins[0].constructor === Array) plugins = plugins[0]; - for (let i in plugins) { - let plugin = plugins[i]; + plugins.forEach(plugin => { if (!plugin.prototype || !plugin.prototype.constructor) { throw `Sortable: Mounted plugin must be a constructor function, not ${ {}.toString.call(el) }`; } if (plugin.utils) Sortable.utils = { ...Sortable.utils, ...plugin.utils }; PluginManager.mount(plugin); - } + }); };