koel/resources/assets/js/directives/newTab.ts

10 lines
317 B
TypeScript
Raw Normal View History

import type { Directive } from 'vue'
2024-05-19 05:49:42 +00:00
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),
2024-05-19 05:49:42 +00:00
}