lib/wrap.js
function listenRemoved(el, cb) {  // {{{2
/*
 * Element wrappers that has `wrap._removed = function() {...}` method defined must be removed by calling `wrap.remove()`
 */

  while (el) {
    if (el.ose && el.ose._removed) {
      if ('_on_removed' in el.ose) {
        el.ose._on_removed.push(cb);
        return;
      }

      el.ose._on_removed = [cb];
      return;
    }

    el = el.parentNode;
  }

  setTimeout(function() {
    if (! el.parentNode) {
      throw O.log.error('Can\'t listen to "removed" event on orphaned child');
    }

    listenRemoved(el, cb);
  });
}
function listenRemoved(el, cb) {  // {{{2
/*
 * Element wrappers that has `wrap._removed = function() {...}` method defined must be removed by calling `wrap.remove()`
 */

  while (el) {
    if (el.ose && el.ose._removed) {
      if ('_on_removed' in el.ose) {
        el.ose._on_removed.push(cb);
        return;
      }

      el.ose._on_removed = [cb];
      return;
    }

    el = el.parentNode;
  }

  setTimeout(function() {
    if (! el.parentNode) {
      throw O.log.error('Can\'t listen to "removed" event on orphaned child');
    }

    listenRemoved(el, cb);
  });
}
Private {{{1