@@ -56,6 +56,9 @@ const CONTAINER_SELECTOR = [MODAL_SELECTOR, SIDEBAR_SELECTOR].join(', ')
5656const DROPDOWN_CLASS = 'dropdown'
5757const DROPDOWN_OPEN_SELECTOR = '.dropdown-menu.show'
5858
59+ // Data attribute to temporary store the `title` attribute's value
60+ const DATA_TITLE_ATTR = 'data-original-title'
61+
5962// Data specific to popper and template
6063// We don't use props, as we need reactivity (we can't pass reactive props)
6164const templateData = {
@@ -200,8 +203,18 @@ export const BVTooltip = /*#__PURE__*/ Vue.extend({
200203 // ensure that the template updates accordingly
201204 this . handleTemplateUpdate ( )
202205 } ,
203- disabled ( newVal ) {
204- newVal ? this . disable ( ) : this . enable ( )
206+ title ( newValue , oldValue ) {
207+ // Make sure to hide the tooltip when the title is set empty
208+ if ( newValue !== oldValue && ! newValue ) {
209+ this . hide ( )
210+ }
211+ } ,
212+ disabled ( newValue ) {
213+ if ( newValue ) {
214+ this . disable ( )
215+ } else {
216+ this . enable ( )
217+ }
205218 }
206219 } ,
207220 created ( ) {
@@ -272,10 +285,10 @@ export const BVTooltip = /*#__PURE__*/ Vue.extend({
272285 }
273286 }
274287 } )
288+ // If the title has updated, we may need to handle the `title`
289+ // attribute on the trigger target
290+ // We only do this while the template is open
275291 if ( titleUpdated && this . localShow ) {
276- // If the title has updated, we may need to handle the title
277- // attribute on the trigger target. We only do this while the
278- // template is open
279292 this . fixTitle ( )
280293 }
281294 } ,
@@ -594,22 +607,19 @@ export const BVTooltip = /*#__PURE__*/ Vue.extend({
594607 }
595608 } ,
596609 fixTitle ( ) {
597- // If the target has a title attribute, null it out and
598- // store on data-title
610+ // If the target has a `title` attribute, remove it and store it on a data attribute
599611 const target = this . getTarget ( )
600- if ( target && getAttr ( target , 'title' ) ) {
601- // We only update title attribute if it has a value
602- setAttr ( target , 'data-original-title' , getAttr ( target , 'title' ) || '' )
612+ if ( target && hasAttr ( target , 'title' ) ) {
613+ setAttr ( target , DATA_TITLE_ATTR , getAttr ( target , 'title' ) || '' )
603614 setAttr ( target , 'title' , '' )
604615 }
605616 } ,
606617 restoreTitle ( ) {
607- // If target had a title, restore the title attribute
608- // and remove the data-title attribute
618+ // If the target had a title, restore it and remove the data attribute
609619 const target = this . getTarget ( )
610- if ( target && hasAttr ( target , 'data-original-title' ) ) {
611- setAttr ( target , 'title' , getAttr ( target , 'data-original-title' ) || '' )
612- removeAttr ( target , 'data-original-title' )
620+ if ( target && hasAttr ( target , DATA_TITLE_ATTR ) ) {
621+ setAttr ( target , 'title' , getAttr ( target , DATA_TITLE_ATTR ) || '' )
622+ removeAttr ( target , DATA_TITLE_ATTR )
613623 }
614624 } ,
615625 // --- BvEvent helpers ---
0 commit comments