@@ -199,6 +199,7 @@ return $.widget( "ui.tooltip", {
199
199
} ) ;
200
200
}
201
201
202
+ this . _registerCloseHandlers ( event , target ) ;
202
203
this . _updateContent ( target , event ) ;
203
204
} ,
204
205
@@ -214,13 +215,16 @@ return $.widget( "ui.tooltip", {
214
215
}
215
216
216
217
content = contentOption . call ( target [ 0 ] , function ( response ) {
217
- // ignore async response if tooltip was closed already
218
- if ( ! target . data ( "ui-tooltip-open" ) ) {
219
- return ;
220
- }
218
+
221
219
// IE may instantly serve a cached response for ajax requests
222
220
// delay this call to _open so the other call to _open runs first
223
221
that . _delay ( function ( ) {
222
+
223
+ // Ignore async response if tooltip was closed already
224
+ if ( ! target . data ( "ui-tooltip-open" ) ) {
225
+ return ;
226
+ }
227
+
224
228
// jQuery creates a special event for focusin when it doesn't
225
229
// exist natively. To improve performance, the native event
226
230
// object is reused and the type is changed. Therefore, we can't
@@ -238,7 +242,7 @@ return $.widget( "ui.tooltip", {
238
242
} ,
239
243
240
244
_open : function ( event , target , content ) {
241
- var tooltipData , tooltip , events , delayedShow , a11yContent ,
245
+ var tooltipData , tooltip , delayedShow , a11yContent ,
242
246
positionOption = $ . extend ( { } , this . options . position ) ;
243
247
244
248
if ( ! content ) {
@@ -316,8 +320,10 @@ return $.widget( "ui.tooltip", {
316
320
}
317
321
318
322
this . _trigger ( "open" , event , { tooltip : tooltip } ) ;
323
+ } ,
319
324
320
- events = {
325
+ _registerCloseHandlers : function ( event , target ) {
326
+ var events = {
321
327
keyup : function ( event ) {
322
328
if ( event . keyCode === $ . ui . keyCode . ESCAPE ) {
323
329
var fakeEvent = $ . Event ( event ) ;
@@ -331,7 +337,7 @@ return $.widget( "ui.tooltip", {
331
337
// tooltips will handle this in destroy.
332
338
if ( target [ 0 ] !== this . element [ 0 ] ) {
333
339
events . remove = function ( ) {
334
- this . _removeTooltip ( tooltip ) ;
340
+ this . _removeTooltip ( this . _find ( target ) . tooltip ) ;
335
341
} ;
336
342
}
337
343
@@ -352,6 +358,12 @@ return $.widget( "ui.tooltip", {
352
358
353
359
// The tooltip may already be closed
354
360
if ( ! tooltipData ) {
361
+
362
+ // We set ui-tooltip-open immediately upon open (in open()), but only set the
363
+ // additional data once there's actually content to show (in _open()). So even if the
364
+ // tooltip doesn't have full data, we always remove ui-tooltip-open in case we're in
365
+ // the period between open() and _open().
366
+ target . removeData ( "ui-tooltip-open" ) ;
355
367
return ;
356
368
}
357
369
0 commit comments