Search code examples
javascriptshorthand

Can you un-shorthand this statement?


I am trying to understand this part of a module:

(isOwner
    ? canSort || (revert = !rootEl.contains(dragEl)) 
    : (
        putSortable === this ||
        activeGroup.checkPull(this, activeSortable, dragEl, evt) && group.checkPut(this, activeSortable, dragEl, evt)
      )
)

Could someone "un-shorthand" this for me?
This is part of an IF statement and returns true/false.


Solution

  • It look likes this:

    if (isOwner) {
        if (canSort) {
          return true;
        } else {
          return (revert = !rootEl.contains(dragEl));
        }
    } else {
      if (putSortable === this) {
        return true;
      } else {
        return activeGroup.checkPull(this, activeSortable, dragEl, evt) && group.checkPut(this, activeSortable, dragEl, evt);
      }
    }