Tooltip: Use attributes, not properties, when checking for parent tooltips. Fixes #8742 - Tooltip shows incorrect message in chrome if there is input with name='title' in a form.

(cherry picked from commit d074efe528)
This commit is contained in:
Scott González 2012-10-28 20:28:55 -04:00
parent 2e9fb43e38
commit 48398bc58c
3 changed files with 33 additions and 7 deletions

View File

@ -46,6 +46,10 @@
<span id="contains-tooltipped" title="parent"><span id="contained-tooltipped" title="child">baz</span></span> <span id="contains-tooltipped" title="parent"><span id="contained-tooltipped" title="child">baz</span></span>
</div> </div>
<form id="tooltip-form">
<input name="title" title="attroperties">
</form>
</div> </div>
</body> </body>
</html> </html>

View File

@ -73,4 +73,25 @@ test( "nested tooltips", function() {
equal( $( ".ui-tooltip" ).text(), "child" ); equal( $( ".ui-tooltip" ).text(), "child" );
}); });
// #8742
test( "form containing an input with name title", function() {
expect( 4 );
var form = $( "#tooltip-form" ).tooltip({
show: null,
hide: null
}),
input = form.find( "[name=title]" );
equal( $( ".ui-tooltip" ).length, 0, "no tooltips on init" );
input.trigger( "mouseover" );
equal( $( ".ui-tooltip" ).length, 1, "tooltip for input" );
input.trigger( "mouseleave" );
equal( $( ".ui-tooltip" ).length, 0, "tooltip for input closed" );
form.trigger( "mouseover" );
equal( $( ".ui-tooltip" ).length, 0, "no tooltip for form" );
});
}( jQuery ) ); }( jQuery ) );

View File

@ -164,19 +164,20 @@ $.widget( "ui.tooltip", {
// kill parent tooltips, custom or native, for hover // kill parent tooltips, custom or native, for hover
if ( event && event.type === "mouseover" ) { if ( event && event.type === "mouseover" ) {
target.parents().each(function() { target.parents().each(function() {
var blurEvent; var parent = $( this ),
if ( $( this ).data( "tooltip-open" ) ) { blurEvent;
if ( parent.data( "tooltip-open" ) ) {
blurEvent = $.Event( "blur" ); blurEvent = $.Event( "blur" );
blurEvent.target = blurEvent.currentTarget = this; blurEvent.target = blurEvent.currentTarget = this;
that.close( blurEvent, true ); that.close( blurEvent, true );
} }
if ( this.title ) { if ( parent.attr( "title" ) ) {
$( this ).uniqueId(); parent.uniqueId();
that.parents[ this.id ] = { that.parents[ this.id ] = {
element: this, element: this,
title: this.title title: parent.attr( "title" )
}; };
this.title = ""; parent.attr( "title", "" );
} }
}); });
} }
@ -334,7 +335,7 @@ $.widget( "ui.tooltip", {
if ( event && event.type === "mouseleave" ) { if ( event && event.type === "mouseleave" ) {
$.each( this.parents, function( id, parent ) { $.each( this.parents, function( id, parent ) {
parent.element.title = parent.title; $( parent.element ).attr( "title", parent.title );
delete that.parents[ id ]; delete that.parents[ id ];
}); });
} }