bootstrap-vue
Version:
BootstrapVue provides one of the most comprehensive implementations of Bootstrap 4 components and grid system for Vue.js and with extensive and automated WAI-ARIA accessibility markup.
29 lines (26 loc) • 958 B
JavaScript
import { bindTargets, unbindTargets } from '../../utils/target';
import { setAttr, removeAttr } from '../../utils/dom';
var listenTypes = { click: true };
export default {
// eslint-disable-next-line no-shadow-restricted-names
bind: function bind(el, binding, vnode) {
bindTargets(vnode, binding, listenTypes, function (_ref) {
var targets = _ref.targets,
vnode = _ref.vnode;
targets.forEach(function (target) {
vnode.context.$root.$emit('bv::show::modal', target, vnode.elm);
});
});
if (el.tagName !== 'BUTTON') {
// If element is not a button, we add `role="button"` for accessibility
setAttr(el, 'role', 'button');
}
},
unbind: function unbind(el, binding, vnode) {
unbindTargets(vnode, binding, listenTypes);
if (el.tagName !== 'BUTTON') {
// If element is not a button, we add `role="button"` for accessibility
removeAttr(el, 'role', 'button');
}
}
};