Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/unit/tooltip/tooltip.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ <h2 id="qunit-userAgent"></h2>
<input title="inputtitle">
<span id="multiple-describedby" aria-describedby="fixture-span" title="...">aria-describedby</span>
<span id="fixture-span" title="title-text">span</span>
<span id="contains-tooltipped"><span id="contained-tooltipped" title="foobar">baz</span></span>
</div>

</div>
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/tooltip/tooltip_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,18 @@ test( "accessibility", function() {
equal( element.attr( "title" ), "...", "title restored when closed" );
});

test( "delegated removal", function() {
expect( 2 );

var tooltip,
container = $( "#contains-tooltipped" ).tooltip(),
element = $( "#contained-tooltipped" );

element.trigger( "mouseover" );
equal( $( ".ui-tooltip" ).length, 1 );

container.empty();
equal( $( ".ui-tooltip" ).length, 0 );
});

}( jQuery ) );
12 changes: 10 additions & 2 deletions ui/jquery.ui.tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ $.widget( "ui.tooltip", {

_open: function( event, target, content ) {
var tooltip, positionOption;

if ( !content ) {
return;
}
Expand Down Expand Up @@ -244,6 +245,9 @@ $.widget( "ui.tooltip", {
fakeEvent.currentTarget = target[0];
this.close( fakeEvent, true );
}
},
remove: function( event ) {
this._removeTooltip( tooltip );
}
});
},
Expand Down Expand Up @@ -278,8 +282,7 @@ $.widget( "ui.tooltip", {

tooltip.stop( true );
this._hide( tooltip, this.options.hide, function() {
$( this ).remove();
delete that.tooltips[ this.id ];
that._removeTooltip( $( this ) );
});

target.removeData( "tooltip-open" );
Expand Down Expand Up @@ -316,6 +319,11 @@ $.widget( "ui.tooltip", {
return id ? $( "#" + id ) : $();
},

_removeTooltip: function( tooltip ) {
tooltip.remove();
delete this.tooltips[ tooltip.attr( "id" ) ];
},

_destroy: function() {
var that = this;

Expand Down