Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Vue 3 #52

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions dist/vue-clickaway.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Vue = 'default' in Vue ? Vue['default'] : Vue;

var version = '2.2.2';

var compatible = (/^2\./).test(Vue.version);
var compatible = (/^3\./).test(Vue.version);
if (!compatible) {
Vue.util.warn('VueClickaway ' + version + ' only supports Vue 2.x, and does not support Vue ' + Vue.version);
console.error('VueClickaway ' + version + ' only supports Vue 3.x, and does not support Vue ' + Vue.version);
}


Expand All @@ -24,7 +24,7 @@ function bind(el, binding, vnode) {
var callback = binding.value;
if (typeof callback !== 'function') {
if (process.env.NODE_ENV !== 'production') {
Vue.util.warn(
console.error(
'v-' + binding.name + '="' +
binding.expression + '" expects a function value, ' +
'got ' + callback
Expand Down Expand Up @@ -58,20 +58,22 @@ function bind(el, binding, vnode) {
};

document.documentElement.addEventListener('click', el[HANDLER], false);
document.documentElement.addEventListener('contextmenu', el[HANDLER], false);
}

function unbind(el) {
document.documentElement.removeEventListener('click', el[HANDLER], false);
document.documentElement.removeEventListener('contextmenu', el[HANDLER], false);
delete el[HANDLER];
}

var directive = {
bind: bind,
update: function(el, binding) {
beforeMount: bind,
updated: function(el, binding) {
if (binding.value === binding.oldValue) return;
bind(el, binding);
},
unbind: unbind,
unmounted: unbind,
};

var mixin = {
Expand Down
16 changes: 9 additions & 7 deletions dist/vue-clickaway.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

var version = '2.2.2';

var compatible = (/^2\./).test(Vue.version);
var compatible = (/^3\./).test(Vue.version);
if (!compatible) {
Vue.util.warn('VueClickaway ' + version + ' only supports Vue 2.x, and does not support Vue ' + Vue.version);
console.error('VueClickaway ' + version + ' only supports Vue 3.x, and does not support Vue ' + Vue.version);
}


Expand All @@ -23,7 +23,7 @@
var callback = binding.value;
if (typeof callback !== 'function') {
if ('development' !== 'production') {
Vue.util.warn(
console.error(
'v-' + binding.name + '="' +
binding.expression + '" expects a function value, ' +
'got ' + callback
Expand All @@ -45,7 +45,7 @@
}, 0);

el[HANDLER] = function(ev) {
// @NOTE: this test used to be just `el.contains`, but working with path is better,
// @NOTE: this test used to be just `el.containts`, but working with path is better,
// because it tests whether the element was there at the time of
// the click, not whether it is there now, that the event has arrived
// to the top.
Expand All @@ -57,20 +57,22 @@
};

document.documentElement.addEventListener('click', el[HANDLER], false);
document.documentElement.addEventListener('contextmenu', el[HANDLER], false);
}

function unbind(el) {
document.documentElement.removeEventListener('click', el[HANDLER], false);
document.documentElement.removeEventListener('contextmenu', el[HANDLER], false);
delete el[HANDLER];
}

var directive = {
bind: bind,
update: function(el, binding) {
beforeMount: bind,
updated: function(el, binding) {
if (binding.value === binding.oldValue) return;
bind(el, binding);
},
unbind: unbind,
unmounted: unbind,
};

var mixin = {
Expand Down
2 changes: 1 addition & 1 deletion dist/vue-clickaway.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import Vue from 'vue';

export var version = '2.2.2';

var compatible = (/^2\./).test(Vue.version);
var compatible = (/^3\./).test(Vue.version);
if (!compatible) {
Vue.util.warn('VueClickaway ' + version + ' only supports Vue 2.x, and does not support Vue ' + Vue.version);
console.error('VueClickaway ' + version + ' only supports Vue 3.x, and does not support Vue ' + Vue.version);
}


Expand All @@ -21,7 +21,7 @@ function bind(el, binding, vnode) {
var callback = binding.value;
if (typeof callback !== 'function') {
if (process.env.NODE_ENV !== 'production') {
Vue.util.warn(
console.error(
'v-' + binding.name + '="' +
binding.expression + '" expects a function value, ' +
'got ' + callback
Expand Down Expand Up @@ -55,20 +55,22 @@ function bind(el, binding, vnode) {
};

document.documentElement.addEventListener('click', el[HANDLER], false);
document.documentElement.addEventListener('contextmenu', el[HANDLER], false);
}

function unbind(el) {
document.documentElement.removeEventListener('click', el[HANDLER], false);
document.documentElement.removeEventListener('contextmenu', el[HANDLER], false);
delete el[HANDLER];
}

export var directive = {
bind: bind,
update: function(el, binding) {
beforeMount: bind,
updated: function(el, binding) {
if (binding.value === binding.oldValue) return;
bind(el, binding);
},
unbind: unbind,
unmounted: unbind,
};

export var mixin = {
Expand Down
Loading