]> source.dussan.org Git - jquery-ui.git/commitdiff
Tooltip: Check if event exists before checking properties in open(). Fixes #8626...
authorScott González <scott.gonzalez@gmail.com>
Fri, 5 Oct 2012 15:26:49 +0000 (11:26 -0400)
committerScott González <scott.gonzalez@gmail.com>
Fri, 5 Oct 2012 15:26:49 +0000 (11:26 -0400)
tests/unit/tooltip/tooltip_methods.js
ui/jquery.ui.tooltip.js

index 0af1e06e95fabb3401b7b7a87adccf6cc70e4dcc..896e910c608cf15c39bcb869d0cb78af18934d84 100644 (file)
@@ -29,6 +29,23 @@ test( "open/close", function() {
        $.fx.off = false;
 });
 
+// #8626 - Calling open() without an event
+test( "open/close with tracking", function() {
+       expect( 3 );
+       $.fx.off = true;
+       var tooltip,
+               element = $( "#tooltipped1" ).tooltip({ track: true });
+       equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
+
+       element.tooltip( "open" );
+       tooltip = $( "#" + element.data( "ui-tooltip-id" ) );
+       ok( tooltip.is( ":visible" ) );
+
+       element.tooltip( "close" );
+       ok( tooltip.is( ":hidden" ) );
+       $.fx.off = false;
+});
+
 test( "enable/disable", function() {
        expect( 7 );
        $.fx.off = true;
index a97d698e302b17b7a34a456c7767d5bc0840c7c2..32aad6487533d3a0f60ad8e1b6639a9563709d98 100644 (file)
@@ -216,7 +216,7 @@ $.widget( "ui.tooltip", {
                        positionOption.of = event;
                        tooltip.position( positionOption );
                }
-               if ( this.options.track && /^mouse/.test( event.originalEvent.type ) ) {
+               if ( this.options.track && event && /^mouse/.test( event.originalEvent.type ) ) {
                        positionOption = $.extend( {}, this.options.position );
                        this._on( this.document, {
                                mousemove: position