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.

This commit is contained in:
Scott González 2012-10-28 20:28:55 -04:00
parent 9473ea7186
commit d074efe528
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>
</div>
<form id="tooltip-form">
<input name="title" title="attroperties">
</form>
</div>
</body>
</html>

View File

@ -73,4 +73,25 @@ test( "nested tooltips", function() {
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 ) );

View File

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