mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
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:
parent
2e9fb43e38
commit
48398bc58c
@ -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>
|
||||
|
@ -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 ) );
|
||||
|
15
ui/jquery.ui.tooltip.js
vendored
15
ui/jquery.ui.tooltip.js
vendored
@ -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 ];
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user