diff options
author | Scott González <scott.gonzalez@gmail.com> | 2012-10-28 20:28:55 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2012-10-28 20:28:55 -0400 |
commit | d074efe5289db4f5182a685046e9b9ad6186ac26 (patch) | |
tree | d659301eda82d13ef6edbb63ed2577e96a38716c | |
parent | 9473ea71866e5eae1c0f242c0b88bb786aa4569b (diff) | |
download | jquery-ui-d074efe5289db4f5182a685046e9b9ad6186ac26.tar.gz jquery-ui-d074efe5289db4f5182a685046e9b9ad6186ac26.zip |
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.
-rw-r--r-- | tests/unit/tooltip/tooltip.html | 4 | ||||
-rw-r--r-- | tests/unit/tooltip/tooltip_core.js | 21 | ||||
-rw-r--r-- | ui/jquery.ui.tooltip.js | 15 |
3 files changed, 33 insertions, 7 deletions
diff --git a/tests/unit/tooltip/tooltip.html b/tests/unit/tooltip/tooltip.html index ca5a1239a..ec616be13 100644 --- a/tests/unit/tooltip/tooltip.html +++ b/tests/unit/tooltip/tooltip.html @@ -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> diff --git a/tests/unit/tooltip/tooltip_core.js b/tests/unit/tooltip/tooltip_core.js index 6e9bee208..f0aed72aa 100644 --- a/tests/unit/tooltip/tooltip_core.js +++ b/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 ) ); diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index f1f919ad3..c05be1d45 100644 --- a/ui/jquery.ui.tooltip.js +++ b/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 ]; }); } |