Browse Source

don't nest parent in child Sortable

when nesting Sortable's, we're not interested in this error:
"HierarchyRequestError: Failed to execute 'appendChild' on 'Node': The new child element contains the parent."
pull/526/head
Paolo Priotto 9 years ago
parent
commit
e51dc53982
  1. 14
      Sortable.js
  2. 2
      Sortable.min.js

14
Sortable.js

@ -603,7 +603,9 @@
_cloneHide(isOwner); _cloneHide(isOwner);
if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect) !== false) { if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect) !== false) {
el.appendChild(dragEl); if (!dragEl.contains(el)) {
el.appendChild(dragEl);
}
this._animate(dragRect, dragEl); this._animate(dragRect, dragEl);
target && this._animate(targetRect, target); target && this._animate(targetRect, target);
} }
@ -644,10 +646,12 @@
after = (nextSibling !== dragEl) && !isLong || halfway && isLong; after = (nextSibling !== dragEl) && !isLong || halfway && isLong;
} }
if (after && !nextSibling) { if (!dragEl.contains(el)) {
el.appendChild(dragEl); if (after && !nextSibling) {
} else { el.appendChild(dragEl);
target.parentNode.insertBefore(dragEl, after ? nextSibling : target); } else {
target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
}
} }
this._animate(dragRect, dragEl); this._animate(dragRect, dragEl);

2
Sortable.min.js vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save