88import type {
99 Binding ,
1010 Content ,
11+ Modifier ,
1112 TooltipDirective ,
1213} from './types.ts'
1314import { ensureKey } from './utils'
@@ -22,6 +23,17 @@ const toContent = (value: Binding): Content =>
2223const extractPlacement = ( value : Binding ) =>
2324 typeof value === 'string' ? 'top' : value . placement
2425
26+ const truncationDirection = (
27+ modifiers : Partial < Record < Modifier , boolean | undefined > > ,
28+ ) => {
29+ if ( modifiers . none ) return 'none'
30+ if ( modifiers . both ) return 'both'
31+ if ( modifiers . x && modifiers . y ) return 'both'
32+ if ( modifiers . x ) return 'x'
33+ if ( modifiers . y ) return 'y'
34+ return options . defaultTruncateDetection
35+ }
36+
2537export const vueltipDirective = {
2638 updated : ( el , binding ) => {
2739 ensureKey ( el , ( key ) =>
@@ -37,6 +49,10 @@ export const vueltipDirective = {
3749 options . placementAttribute ,
3850 extractPlacement ( binding . value ) ,
3951 )
52+ el . setAttribute (
53+ options . truncateAttribute ,
54+ truncationDirection ( binding . modifiers ?? { } ) ,
55+ )
4056
4157 el . addEventListener ( 'mouseenter' , onMouseover )
4258 el . addEventListener ( 'focus' , onMouseover )
0 commit comments