code: function clickOutside(elements, fn) {
    const self = {
      on,
      off,
      isClicked
    };
  
    let clickedEl;
    let handlers;
  
    function stop(e) {
      clickedEl = this;
      e.stopPropagation();
    }
  
    function pass() {
      clickedEl = undefined;
      fn();
    }
  
    function isClicked(el) {
      return el === clickedEl;
    }
  
    function on() {
      const html = document.documentElement;
      handlers = elements.map(function(el) {
        const handler = stop.bind(el);
        el.addEventListener('mousedown', handler);
        return handler;
      });
      html.addEventListener('mousedown', pass);
      return self;
    }
  
    function off() {
      const html = document.documentElement;
      html.removeEventListener('mousedown', pass);
      elements.forEach(function(el, i) {
        el.removeEventListener('mousedown', handlers[i]);
      });
      return self;
    }
  
    return self;
  }
docs: /*global document