From feaf39b41b6b274bb637149c4311ba783360c11a Mon Sep 17 00:00:00 2001 From: maxim Date: Tue, 15 Dec 2020 03:41:20 +0100 Subject: [PATCH] make Vue 3.x compatible (breaking!) --- index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index d59d224..0524e74 100644 --- a/index.js +++ b/index.js @@ -32,18 +32,18 @@ function isServer(vNode) { } exports = module.exports = { - bind: function (el, binding, vNode) { + beforeMount: function (el, binding, vNode) { if (!validate(binding)) return // Define Handler and cache it on the element function handler(e) { - if (!vNode.context) return + if (!binding.instance) return // some components may have related popup item, on which we shall prevent the click outside event handler. var elements = e.path || (e.composedPath && e.composedPath()) elements && elements.length > 0 && elements.unshift(e.target) - if (el.contains(e.target) || isPopup(vNode.context.popupItem, elements)) return + if (el.contains(e.target) || isPopup(binding.instance.popupItem, elements)) return el.__vueClickOutside__.callback(e) } @@ -57,11 +57,11 @@ exports = module.exports = { !isServer(vNode) && document.addEventListener(clickHandler, handler) }, - update: function (el, binding) { + updated: function (el, binding) { if (validate(binding)) el.__vueClickOutside__.callback = binding.value }, - unbind: function (el, binding, vNode) { + unmounted: function (el, binding, vNode) { // Remove Event Listeners const clickHandler = 'ontouchstart' in document.documentElement ? 'touchstart' : 'click'; !isServer(vNode) && el.__vueClickOutside__ && document.removeEventListener(clickHandler, el.__vueClickOutside__.handler)