Skip to content

Commit d074efe

Browse files
committed
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.
1 parent 9473ea7 commit d074efe

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

tests/unit/tooltip/tooltip.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ <h2 id="qunit-userAgent"></h2>
4646
<span id="contains-tooltipped" title="parent"><span id="contained-tooltipped" title="child">baz</span></span>
4747
</div>
4848

49+
<form id="tooltip-form">
50+
<input name="title" title="attroperties">
51+
</form>
52+
4953
</div>
5054
</body>
5155
</html>

tests/unit/tooltip/tooltip_core.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,25 @@ test( "nested tooltips", function() {
7373
equal( $( ".ui-tooltip" ).text(), "child" );
7474
});
7575

76+
// #8742
77+
test( "form containing an input with name title", function() {
78+
expect( 4 );
79+
80+
var form = $( "#tooltip-form" ).tooltip({
81+
show: null,
82+
hide: null
83+
}),
84+
input = form.find( "[name=title]" );
85+
86+
equal( $( ".ui-tooltip" ).length, 0, "no tooltips on init" );
87+
88+
input.trigger( "mouseover" );
89+
equal( $( ".ui-tooltip" ).length, 1, "tooltip for input" );
90+
input.trigger( "mouseleave" );
91+
equal( $( ".ui-tooltip" ).length, 0, "tooltip for input closed" );
92+
93+
form.trigger( "mouseover" );
94+
equal( $( ".ui-tooltip" ).length, 0, "no tooltip for form" );
95+
});
96+
7697
}( jQuery ) );

ui/jquery.ui.tooltip.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,20 @@ $.widget( "ui.tooltip", {
164164
// kill parent tooltips, custom or native, for hover
165165
if ( event && event.type === "mouseover" ) {
166166
target.parents().each(function() {
167-
var blurEvent;
168-
if ( $( this ).data( "tooltip-open" ) ) {
167+
var parent = $( this ),
168+
blurEvent;
169+
if ( parent.data( "tooltip-open" ) ) {
169170
blurEvent = $.Event( "blur" );
170171
blurEvent.target = blurEvent.currentTarget = this;
171172
that.close( blurEvent, true );
172173
}
173-
if ( this.title ) {
174-
$( this ).uniqueId();
174+
if ( parent.attr( "title" ) ) {
175+
parent.uniqueId();
175176
that.parents[ this.id ] = {
176177
element: this,
177-
title: this.title
178+
title: parent.attr( "title" )
178179
};
179-
this.title = "";
180+
parent.attr( "title", "" );
180181
}
181182
});
182183
}
@@ -334,7 +335,7 @@ $.widget( "ui.tooltip", {
334335

335336
if ( event && event.type === "mouseleave" ) {
336337
$.each( this.parents, function( id, parent ) {
337-
parent.element.title = parent.title;
338+
$( parent.element ).attr( "title", parent.title );
338339
delete that.parents[ id ];
339340
});
340341
}

0 commit comments

Comments
 (0)