@@ -194,6 +194,7 @@ return $.widget( "ui.tooltip", {
194194 } ) ;
195195 }
196196
197+ this . _registerCloseHandlers ( event , target ) ;
197198 this . _updateContent ( target , event ) ;
198199 } ,
199200
@@ -208,13 +209,16 @@ return $.widget( "ui.tooltip", {
208209 }
209210
210211 content = contentOption . call ( target [ 0 ] , function ( response ) {
211- // ignore async response if tooltip was closed already
212- if ( ! target . data ( "ui-tooltip-open" ) ) {
213- return ;
214- }
212+
215213 // IE may instantly serve a cached response for ajax requests
216214 // delay this call to _open so the other call to _open runs first
217215 that . _delay ( function ( ) {
216+
217+ // Ignore async response if tooltip was closed already
218+ if ( ! target . data ( "ui-tooltip-open" ) ) {
219+ return ;
220+ }
221+
218222 // jQuery creates a special event for focusin when it doesn't
219223 // exist natively. To improve performance, the native event
220224 // object is reused and the type is changed. Therefore, we can't
@@ -232,7 +236,7 @@ return $.widget( "ui.tooltip", {
232236 } ,
233237
234238 _open : function ( event , target , content ) {
235- var tooltipData , tooltip , events , delayedShow , a11yContent ,
239+ var tooltipData , tooltip , delayedShow , a11yContent ,
236240 positionOption = $ . extend ( { } , this . options . position ) ;
237241
238242 if ( ! content ) {
@@ -314,8 +318,10 @@ return $.widget( "ui.tooltip", {
314318 }
315319
316320 this . _trigger ( "open" , event , { tooltip : tooltip } ) ;
321+ } ,
317322
318- events = {
323+ _registerCloseHandlers : function ( event , target ) {
324+ var events = {
319325 keyup : function ( event ) {
320326 if ( event . keyCode === $ . ui . keyCode . ESCAPE ) {
321327 var fakeEvent = $ . Event ( event ) ;
@@ -329,7 +335,7 @@ return $.widget( "ui.tooltip", {
329335 // tooltips will handle this in destroy.
330336 if ( target [ 0 ] !== this . element [ 0 ] ) {
331337 events . remove = function ( ) {
332- this . _removeTooltip ( tooltip ) ;
338+ this . _removeTooltip ( this . _find ( target ) . tooltip ) ;
333339 } ;
334340 }
335341
@@ -350,6 +356,12 @@ return $.widget( "ui.tooltip", {
350356
351357 // The tooltip may already be closed
352358 if ( ! tooltipData ) {
359+
360+ // We set ui-tooltip-open immediately upon open (in open()), but only set the
361+ // additional data once there's actually content to show (in _open()). So even if the
362+ // tooltip doesn't have full data, we always remove ui-tooltip-open in case we're in
363+ // the period between open() and _open().
364+ target . removeData ( "ui-tooltip-open" ) ;
353365 return ;
354366 }
355367
0 commit comments