Skip to content
Browse files

Tooltip: Use attributes, not properties, when checking for parent too…

…ltips. Fixes #8742 - Tooltip shows incorrect message in chrome if there is input with name='title' in a form.
  • Loading branch information...
1 parent 9473ea7 commit d074efe5289db4f5182a685046e9b9ad6186ac26 @scottgonzalez scottgonzalez committed
Showing with 33 additions and 7 deletions.
  1. +4 −0 tests/unit/tooltip/tooltip.html
  2. +21 −0 tests/unit/tooltip/tooltip_core.js
  3. +8 −7 ui/jquery.ui.tooltip.js
View
4 tests/unit/tooltip/tooltip.html
@@ -46,6 +46,10 @@ <h2 id="qunit-userAgent"></h2>
<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
21 tests/unit/tooltip/tooltip_core.js
@@ -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
15 ui/jquery.ui.tooltip.js
@@ -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 ];
});
}

1 comment on commit d074efe

@jzaefferer
jQuery Foundation member

I see. Now that's a good reason to not use properties.

Please sign in to comment.
Something went wrong with that request. Please try again.