Skip to content

Commit 917d2b1

Browse files
committed
Tooltip: Don't mess with the title attribute if it doesn't exist. Prevents the creation of a title attribute if there wasn't one to begin with.
1 parent 0bc1c8c commit 917d2b1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

ui/jquery.ui.tooltip.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ $.widget( "ui.tooltip", {
8181
return;
8282
}
8383

84-
target.attr( "title", "" );
84+
// if we have a title, clear it to prevent the native tooltip
85+
// we have to check first to avoid defining a title if none exists
86+
// (we don't want to cause an element to start matching [title])
87+
// TODO: document why we don't use .removeAttr()
88+
if ( target.is( "[title]" ) ) {
89+
target.attr( "title", "" );
90+
}
8591

8692
// TODO: why is this check after we clear the title?
8793
if ( this.options.disabled ) {
@@ -120,7 +126,10 @@ $.widget( "ui.tooltip", {
120126
target = $( event ? event.currentTarget : this.element ),
121127
tooltip = this._find( target );
122128

123-
target.attr( "title", target.data( "tooltip-title" ) );
129+
// only set title if we had one before (see comment in _open())
130+
if ( target.data( "tooltip-title" ) ) {
131+
target.attr( "title", target.data( "tooltip-title" ) );
132+
}
124133

125134
if ( this.options.disabled ) {
126135
return;

0 commit comments

Comments
 (0)