UNPKG

bootstrap-vue

Version:

With more than 85 components, over 45 available plugins, several directives, and 1000+ icons, BootstrapVue provides one of the most comprehensive implementations of the Bootstrap v4 component and grid system available for Vue.js v2.6, complete with extens

26 lines (21 loc) 1.03 kB
// Mixin to determine if an event listener has been registered // either via `v-on:name` (in the parent) or programmatically // via `vm.$on('name', ...)` // See: https://github.com/vuejs/vue/issues/10825 import { isVue3, extend } from '../vue'; import { isArray, isUndefined } from '../utils/inspect'; // @vue/component export var hasListenerMixin = extend({ methods: { hasListener: function hasListener(name) { if (isVue3) { return true; } // Only includes listeners registered via `v-on:name` var $listeners = this.$listeners || {}; // Includes `v-on:name` and `this.$on('name')` registered listeners // Note this property is not part of the public Vue API, but it is // the only way to determine if a listener was added via `vm.$on` var $events = this._events || {}; // Registered listeners in `this._events` are always an array, // but might be zero length return !isUndefined($listeners[name]) || isArray($events[name]) && $events[name].length > 0; } } });