vue-focus
Version:
A set of reusable focus directives for reusable Vue.js components
33 lines (26 loc) • 650 B
JavaScript
import Vue from 'vue';
export var version = '2.1.0';
var compatible = (/^2\./).test(Vue.version);
if (!compatible) {
Vue.util.warn('VueFocus ' + version + ' only supports Vue 2.x, and does not support Vue ' + Vue.version);
}
export var focus = {
inserted: function(el, binding) {
if (binding.value) el.focus();
else el.blur();
},
componentUpdated: function(el, binding) {
if (binding.modifiers.lazy) {
if (Boolean(binding.value) === Boolean(binding.oldValue)) {
return;
}
}
if (binding.value) el.focus();
else el.blur();
},
};
export var mixin = {
directives: {
focus: focus,
},
};