Skip to content

Commit 2155993

Browse files
committed
Tooltip: Fixed tooltipClass option and added test.
1 parent 4dbfdce commit 2155993

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

tests/unit/tooltip/tooltip_options.js

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,6 @@
22

33
module( "tooltip: options" );
44

5-
test( "items", function() {
6-
expect( 2 );
7-
var element = $( "#qunit-fixture" ).tooltip({
8-
items: "#fixture-span"
9-
});
10-
11-
var event = $.Event( "mouseenter" );
12-
event.target = $( "#fixture-span" )[ 0 ];
13-
element.tooltip( "open", event );
14-
same( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "title-text" );
15-
16-
// make sure default [title] doesn't get used
17-
event.target = $( "#tooltipped1" )[ 0 ];
18-
element.tooltip( "open", event );
19-
same( $( "#tooltipped1" ).attr( "aria-describedby" ), undefined );
20-
21-
element.tooltip( "destroy" );
22-
});
23-
245
test( "content: default", function() {
256
var element = $( "#tooltipped1" ).tooltip().tooltip( "open" );
267
same( $( "#" + element.attr( "aria-describedby" ) ).text(), "anchortitle" );
@@ -62,4 +43,31 @@ asyncTest( "content: sync + async callback", function() {
6243
}).tooltip( "open" );
6344
});
6445

46+
test( "items", function() {
47+
expect( 2 );
48+
var element = $( "#qunit-fixture" ).tooltip({
49+
items: "#fixture-span"
50+
});
51+
52+
var event = $.Event( "mouseenter" );
53+
event.target = $( "#fixture-span" )[ 0 ];
54+
element.tooltip( "open", event );
55+
same( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "title-text" );
56+
57+
// make sure default [title] doesn't get used
58+
event.target = $( "#tooltipped1" )[ 0 ];
59+
element.tooltip( "open", event );
60+
same( $( "#tooltipped1" ).attr( "aria-describedby" ), undefined );
61+
62+
element.tooltip( "destroy" );
63+
});
64+
65+
test( "tooltipClass", function() {
66+
expect( 1 )
67+
var element = $( "#tooltipped1" ).tooltip({
68+
tooltipClass: "custom"
69+
}).tooltip( "open" );
70+
ok( $( "#" + element.attr( "aria-describedby" ) ).hasClass( "custom" ) );
71+
});
72+
6573
}( jQuery ) );

ui/jquery.ui.tooltip.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ $.widget( "ui.tooltip", {
142142
id: id,
143143
role: "tooltip"
144144
})
145-
.addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content" +
145+
.addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
146146
( this.options.tooltipClass || "" ) );
147147
$( "<div>" )
148148
.addClass( "ui-tooltip-content" )

0 commit comments

Comments
 (0)