diff options
author | Josep Sanz <josepsanzcamp@gmail.com> | 2021-11-08 11:53:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-08 11:53:45 +0100 |
commit | 85fba3f107a4a03bdac43f06c81ab2f2a3c2fea5 (patch) | |
tree | 3acb7fa147fff79cce1231f82cd709a5158483e0 /ui | |
parent | 1f0851b5381143e78d4ded1877b2a0e4d2aec5ca (diff) | |
download | jquery-ui-85fba3f107a4a03bdac43f06c81ab2f2a3c2fea5.tar.gz jquery-ui-85fba3f107a4a03bdac43f06c81ab2f2a3c2fea5.zip |
Tooltip: Don't crash on empty content
Commit 1f2011ece removed a `try-catch` around triggering the `remove` handlers
in the `jQuery.cleanData` override. The `try-catch` was meant for old IE but it was
also catching an error coming from the tooltip `remove` handler depending on
being able to find a relevant tooltip. The `_find` method returns `null`, though,
when the tooltip cotent is empty.
Instead of restoring the `try-catch`, handle the `null` case in the `remove` handler.
Fixes gh-1990
Closes gh-1994
Co-authored-by: Claas Augner <github@caugner.de>
Co-authored-by: Michał Gołębiowski-Owczarek <m.goleb@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/widgets/tooltip.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ui/widgets/tooltip.js b/ui/widgets/tooltip.js index f1cea47d1..06282338a 100644 --- a/ui/widgets/tooltip.js +++ b/ui/widgets/tooltip.js @@ -352,7 +352,10 @@ $.widget( "ui.tooltip", { // tooltips will handle this in destroy. if ( target[ 0 ] !== this.element[ 0 ] ) { events.remove = function() { - this._removeTooltip( this._find( target ).tooltip ); + var targetElement = this._find( target ); + if ( targetElement ) { + this._removeTooltip( targetElement.tooltip ); + } }; } |