@@ -330,7 +330,6 @@ export const TooltipMixin = (superClass) =>
330330 */
331331 text : {
332332 type : String ,
333- observer : '__textChanged' ,
334333 } ,
335334
336335 /**
@@ -366,26 +365,9 @@ export const TooltipMixin = (superClass) =>
366365 type : Boolean ,
367366 sync : true ,
368367 } ,
369-
370- /** @private */
371- _srLabel : {
372- type : Object ,
373- } ,
374-
375- /** @private */
376- _overlayContent : {
377- type : String ,
378- } ,
379368 } ;
380369 }
381370
382- static get observers ( ) {
383- return [
384- '__generatorChanged(_overlayElement, generator, context)' ,
385- '__updateSrLabelText(_srLabel, _overlayContent)' ,
386- ] ;
387- }
388-
389371 /**
390372 * Sets the default focus delay to be used by all tooltip instances,
391373 * except for those that have focus delay configured using property.
@@ -420,7 +402,6 @@ export const TooltipMixin = (superClass) =>
420402 super ( ) ;
421403
422404 this . _uniqueId = `vaadin-tooltip-${ generateUniqueId ( ) } ` ;
423- this . _renderer = this . __tooltipRenderer . bind ( this ) ;
424405
425406 this . __onFocusin = this . __onFocusin . bind ( this ) ;
426407 this . __onFocusout = this . __onFocusout . bind ( this ) ;
@@ -467,19 +448,24 @@ export const TooltipMixin = (superClass) =>
467448
468449 this . _overlayElement = this . $ . overlay ;
469450
470- this . _srLabelController = new SlotController ( this , 'sr-label ' , 'div' , {
451+ this . __contentController = new SlotController ( this , 'overlay ' , 'div' , {
471452 initializer : ( element ) => {
472453 element . id = this . _uniqueId ;
473454 element . setAttribute ( 'role' , 'tooltip' ) ;
474- this . _srLabel = element ;
455+ this . __contentNode = element ;
475456 } ,
476457 } ) ;
477- this . addController ( this . _srLabelController ) ;
458+ this . addController ( this . __contentController ) ;
478459 }
479460
480- /** @private */
481- __computeOpened ( manual , opened , autoOpened , connected ) {
482- return connected && ( manual ? opened : autoOpened ) ;
461+ /** @protected */
462+ updated ( props ) {
463+ super . updated ( props ) ;
464+
465+ if ( props . has ( 'text' ) || props . has ( 'generator' ) || props . has ( 'context' ) ) {
466+ this . __updateContent ( ) ;
467+ this . $ . overlay . toggleAttribute ( 'hidden' , this . __contentNode . textContent . trim ( ) === '' ) ;
468+ }
483469 }
484470
485471 /** @private */
@@ -688,18 +674,8 @@ export const TooltipMixin = (superClass) =>
688674 }
689675
690676 /** @private */
691- __textChanged ( text , oldText ) {
692- if ( this . _overlayElement && ( text || oldText ) ) {
693- this . _overlayElement . requestContentUpdate ( ) ;
694- }
695- }
696-
697- /** @private */
698- __tooltipRenderer ( root ) {
699- root . textContent = typeof this . generator === 'function' ? this . generator ( this . context ) : this . text ;
700-
701- // Update the sr-only label text content
702- this . _overlayContent = root . textContent ;
677+ __updateContent ( ) {
678+ this . __contentNode . textContent = typeof this . generator === 'function' ? this . generator ( this . context ) : this . text ;
703679 }
704680
705681 /** @private */
@@ -723,23 +699,4 @@ export const TooltipMixin = (superClass) =>
723699 } ) ;
724700 }
725701 }
726-
727- /** @private */
728- __generatorChanged ( overlayElement , generator , context ) {
729- if ( overlayElement ) {
730- if ( generator !== this . __oldTextGenerator || context !== this . __oldContext ) {
731- overlayElement . requestContentUpdate ( ) ;
732- }
733-
734- this . __oldTextGenerator = generator ;
735- this . __oldContext = context ;
736- }
737- }
738-
739- /** @private */
740- __updateSrLabelText ( srLabel , textContent ) {
741- if ( srLabel ) {
742- srLabel . textContent = textContent ;
743- }
744- }
745702 } ;
0 commit comments