Skip to content

Commit a8ff773

Browse files
committed
Tooltip: Only bind remove handler for delegated tooltips
The remove handler was being added for every tooltip, but only removed for delegated tooltips. The default destroy behavior already handles non-delegated tooltips, so the handler should only be added for delegated tooltips. Fixes #9531 Closes jquerygh-1156
1 parent 247257e commit a8ff773

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

ui/jquery.ui.tooltip.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,17 @@ $.widget( "ui.tooltip", {
310310
fakeEvent.currentTarget = target[0];
311311
this.close( fakeEvent, true );
312312
}
313-
},
314-
remove: function() {
315-
this._removeTooltip( tooltip );
316313
}
317314
};
315+
316+
// Only bind remove handler for delegated targets. Non-delegated
317+
// tooltips will handle this in destroy.
318+
if ( target[ 0 ] !== this.element[ 0 ] ) {
319+
events.remove = function() {
320+
this._removeTooltip( tooltip );
321+
};
322+
}
323+
318324
if ( !event || event.type === "mouseover" ) {
319325
events.mouseleave = "close";
320326
}
@@ -353,8 +359,9 @@ $.widget( "ui.tooltip", {
353359

354360
target.removeData( "ui-tooltip-open" );
355361
this._off( target, "mouseleave focusout keyup" );
362+
356363
// Remove 'remove' binding only on delegated targets
357-
if ( target[0] !== this.element[0] ) {
364+
if ( target[ 0 ] !== this.element[ 0 ] ) {
358365
this._off( target, "remove" );
359366
}
360367
this._off( this.document, "mousemove" );

0 commit comments

Comments
 (0)