bootstrap-vue-3
Version:
Early (but lovely) implementation of Vue 3, Bootstrap 5 and Typescript
20 lines (16 loc) • 536 B
text/typescript
import type {Directive, DirectiveBinding} from 'vue'
// TODO data-bs-toggle/target are not valid anymore.
/**
*
* This is not marked as external, but in the future I think it may be
*/
export default {
mounted(el, binding: DirectiveBinding): void {
let target: string = binding.value
if (Object.keys(binding.modifiers).length > 0) {
;[target] = Object.keys(binding.modifiers)
}
el.setAttribute('data-bs-toggle', 'modal')
el.setAttribute('data-bs-target', `#${target}`)
},
} as Directive<HTMLElement>