const ClickOutSide = {
  beforeMount(el, binding) {
    function documentHandler(e) {
      if (el.contains(e.target)) {
        return false
      }
      binding.value(e)
    }
    el.__vueClickOutside__ = documentHandler
    document.addEventListener('click', documentHandler)
  },
  updated(el, binding) {
  },
  unmounted(el) {
    document.removeEventListener('click', el.__vueClickOutside__)
    delete el.__vueClickOutside__
  },
}

export default ClickOutSide
