Skip to content

Commit

Permalink
Fix SortableJS#1539 (when Array.prototype is modified)
Browse files Browse the repository at this point in the history
  • Loading branch information
e.fattal committed Jun 14, 2019
1 parent 2ca1ff5 commit 0169c75
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/Sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
});
};


Expand Down

0 comments on commit 0169c75

Please sign in to comment.