aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/unit/tooltip/tooltip.html2
-rw-r--r--tests/unit/tooltip/tooltip_methods.js10
-rw-r--r--tests/unit/tooltip/tooltip_options.js50
-rw-r--r--ui/jquery.ui.tooltip.js7
4 files changed, 37 insertions, 32 deletions
diff --git a/tests/unit/tooltip/tooltip.html b/tests/unit/tooltip/tooltip.html
index d540504ab..21eff51fd 100644
--- a/tests/unit/tooltip/tooltip.html
+++ b/tests/unit/tooltip/tooltip.html
@@ -37,7 +37,7 @@
<div>
<a id="tooltipped1" href="#" title="anchortitle">anchor</a>
<input title="inputtitle">
- <span id="fixture-span" data-tooltip="text">span</span>
+ <span id="fixture-span" title="title-text">span</span>
</div>
</div>
diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js
index 1487672cb..b1b319d96 100644
--- a/tests/unit/tooltip/tooltip_methods.js
+++ b/tests/unit/tooltip/tooltip_methods.js
@@ -3,9 +3,14 @@
module( "tooltip: methods" );
test( "destroy", function() {
+ expect( 2 );
domEqual( "#tooltipped1", function() {
$( "#tooltipped1" ).tooltip().tooltip( "destroy" );
});
+
+ // make sure that open tooltips are removed on destroy
+ $( "#tooltipped1" ).tooltip().tooltip( "open" ).tooltip( "destroy" );
+ equal( $( ".ui-tooltip" ).length, 0 );
});
test( "open/close", function() {
@@ -13,12 +18,11 @@ test( "open/close", function() {
$.fx.off = true;
var element = $( "#tooltipped1" ).tooltip();
equal( $( ".ui-tooltip" ).length, 0, "no tooltip on init" );
-$( ".ui-tooltip" ).each(function() {
- console.log( $( this ).html() );
-});
+
element.tooltip( "open" );
var tooltip = $( "#" + element.attr( "aria-describedby" ) );
ok( tooltip.is( ":visible" ) );
+
element.tooltip( "close" );
ok( tooltip.is( ":hidden" ) );
$.fx.off = false;
diff --git a/tests/unit/tooltip/tooltip_options.js b/tests/unit/tooltip/tooltip_options.js
index c866d219f..bbbab72ff 100644
--- a/tests/unit/tooltip/tooltip_options.js
+++ b/tests/unit/tooltip/tooltip_options.js
@@ -3,15 +3,21 @@
module( "tooltip: options" );
test( "items", function() {
- var event = $.Event( "mouseenter" );
- event.target = $( "[data-tooltip]" )[ 0 ];
+ expect( 2 );
var element = $( "#qunit-fixture" ).tooltip({
- items: "[data-tooltip]",
- content: function() {
- return $( this ).attr( "data-tooltip" );
- }
- }).tooltip( "open", event );
- same( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "text" );
+ items: "#fixture-span"
+ });
+
+ var event = $.Event( "mouseenter" );
+ event.target = $( "#fixture-span" )[ 0 ];
+ element.tooltip( "open", event );
+ same( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "title-text" );
+
+ // make sure default [title] doesn't get used
+ event.target = $( "#tooltipped1" )[ 0 ];
+ element.tooltip( "open", event );
+ same( $( "#tooltipped1" ).attr( "aria-describedby" ), undefined );
+
element.tooltip( "destroy" );
});
@@ -38,22 +44,22 @@ test( "content: return jQuery", function() {
same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
});
-/*
-TODO broken, probably related to async content
-test("content: callback string", function() {
- stop();
- $("#tooltipped1").tooltip({
- content: function(response) {
- response("customstring2");
+asyncTest( "content: sync + async callback", function() {
+ expect( 2 );
+ var element = $( "#tooltipped1" ).tooltip({
+ content: function( response ) {
setTimeout(function() {
- //console.log($("#tooltipped1").attr("aria-describedby"))
- same( $( "#" + $("#tooltipped1").attr("aria-describedby") ).text(), "customstring2" );
- start();
- }, 100)
+ same( $( "#" + element.attr("aria-describedby") ).text(), "loading..." );
+
+ response( "customstring2" );
+ setTimeout(function() {
+ same( $( "#" + element.attr("aria-describedby") ).text(), "customstring2" );
+ start();
+ }, 13 );
+ }, 13 );
+ return "loading...";
}
- }).tooltip("open");
-
+ }).tooltip( "open" );
});
-*/
}( jQuery ) );
diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js
index e6f1c7bb6..343c1d055 100644
--- a/ui/jquery.ui.tooltip.js
+++ b/ui/jquery.ui.tooltip.js
@@ -63,12 +63,7 @@ $.widget( "ui.tooltip", {
// IE may instantly serve a cached response for ajax requests
// delay this call to _open so the other call to _open runs first
setTimeout(function() {
- // when undefined, it got removeAttr, then ignore (ajax response)
- // initially its an empty string, so not undefined
- // TODO is there a better approach to enable ajax tooltips to have two updates?
- if ( target.attr( "aria-describedby" ) !== undefined ) {
- that._open( event, target, response );
- }
+ that._open( event, target, response );
}, 1 );
});
if ( content ) {