]> source.dussan.org Git - jquery-ui.git/commitdiff
Tooltip: Don't mess with the title attribute if it doesn't exist. Prevents the creati...
authorScott González <scott.gonzalez@gmail.com>
Sun, 29 May 2011 17:34:37 +0000 (13:34 -0400)
committerScott González <scott.gonzalez@gmail.com>
Sun, 29 May 2011 17:34:37 +0000 (13:34 -0400)
ui/jquery.ui.tooltip.js

index c8d892d388bd649cf81d8aa3e95a1c10ec8f5ab6..c5d9508f7ffcf6aa53a64030a4d4965a29b0bba7 100644 (file)
@@ -81,7 +81,13 @@ $.widget( "ui.tooltip", {
                        return;
                }
 
-               target.attr( "title", "" );
+               // if we have a title, clear it to prevent the native tooltip
+               // we have to check first to avoid defining a title if none exists
+               // (we don't want to cause an element to start matching [title])
+               // TODO: document why we don't use .removeAttr()
+               if ( target.is( "[title]" ) ) {
+                       target.attr( "title", "" );
+               }
 
                // TODO: why is this check after we clear the title?
                if ( this.options.disabled ) {
@@ -120,7 +126,10 @@ $.widget( "ui.tooltip", {
                        target = $( event ? event.currentTarget : this.element ),
                        tooltip = this._find( target );
 
-               target.attr( "title", target.data( "tooltip-title" ) );
+               // only set title if we had one before (see comment in _open())
+               if ( target.data( "tooltip-title" ) ) {
+                       target.attr( "title", target.data( "tooltip-title" ) );
+               }
 
                if ( this.options.disabled ) {
                        return;