Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Simplified conditions checking for elements to insert into tooltip.
Fixed the tests.
  • Loading branch information
Daniel Owens committed May 8, 2013
commit 93388dde37b1fb859fa2a4317ad18fa3d780337b
21 changes: 11 additions & 10 deletions tests/unit/tooltip/tooltip_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,32 +95,33 @@ test( "content: string", function() {
equal( ui.tooltip.text(), "just a string" );
}
}).tooltip( "open" );
}
});

test( "content: element", function() {
expect( 1 );
var html = $( "<p>This is a <i>test</i> of the emergency broadcast system.</p>" )[0];
var content = "<p>This is a <i>test</i> of the emergency broadcast system.</p>"
var element = $( content )[ 0 ];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many var statements.

$( "#tooltipped1" ).tooltip({
content: html,
content: element,
open: function( event, ui ) {
equal( ui.tooltip.html(), html );
// Getting just the contents of the tooltip wrapper.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this comment.

equal( ui.tooltip[ 0 ].firstChild.innerHTML, content );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comparison looks questionable. Not sure about a better way to test this. Maybe domEqual can be used here. Also applies to the equal call below.

}
}).tooltip( "open" );
});
);

test( "content: jQuery", function() {
expect( 1 );
var html = $( "<p>This is a <i>test</i> of the emergency broadcast system.</p>" );
var content = "<p>This is a <i>test</i> of the emergency broadcast system.</p>"
var element = $( content );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too may var statements.

$( "#tooltipped1" ).tooltip({
content: html,
content: element,
open: function( event, ui ) {
equal( ui.tooltip.html(), html );
console.log( ui.tooltip );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this.

equal( ui.tooltip[ 0 ].firstChild.innerHTML, content );
}
}).tooltip( "open" );
});
);


test( "items", function() {
expect( 2 );
Expand Down
6 changes: 1 addition & 5 deletions ui/jquery.ui.tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,10 @@ $.widget( "ui.tooltip", {
_updateContent: function( target, event ) {
var content,
contentOption = this.options.content,
contentOptionType = (typeof contentOption),
that = this,
eventType = event ? event.type : null;

if ( contentOptionType === "string" ||
( contentOptionType === "object" &&
( contentOption instanceof HTMLElement || contentOption instanceof jQuery ) )
) {
if ( typeof contentOption === "string" || contentOption.nodeType || contentOption.jquery ) {
return this._open( event, target, contentOption );
}

Expand Down