koel/resources/assets/js/directives/newTab.ts
2024-10-14 00:37:01 +07:00

9 lines
317 B
TypeScript

import type { Directive } from 'vue'
const setTargetBlank = (el: HTMLElement) => Array.from(el.getElementsByTagName('a'))
.forEach(a => a.setAttribute('target', '_blank'))
export const newTab: Directive = {
mounted: (el: HTMLElement) => setTargetBlank(el),
updated: (el: HTMLElement) => setTargetBlank(el),
}