From f883007b7ce5038c50e6fe2fc28fedb118e24a32 Mon Sep 17 00:00:00 2001 From: Daniel Owens Date: Wed, 8 May 2013 12:15:44 -0500 Subject: [PATCH 1/2] Tooltip: Accept HTMLElement and jQuery objects for the content option Fixes #9278 Closes #983 --- tests/unit/tooltip/tooltip_options.js | 24 ++++++++++++++++++++++++ ui/tooltip.js | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/tests/unit/tooltip/tooltip_options.js b/tests/unit/tooltip/tooltip_options.js index 17f0a423775..9af49b49b47 100644 --- a/tests/unit/tooltip/tooltip_options.js +++ b/tests/unit/tooltip/tooltip_options.js @@ -100,6 +100,30 @@ test( "content: string", function() { }).tooltip( "open" ); }); +test( "content: element", function() { + expect( 1 ); + var content = "

This is a test of the emergency broadcast system.

", + element = $( content )[ 0 ]; + $( "#tooltipped1" ).tooltip({ + content: element, + open: function( event, ui ) { + equal( ui.tooltip.children().html(), content ); + } + }).tooltip( "open" ); +}); + +test( "content: jQuery", function() { + expect( 1 ); + var content = "

This is a test of the emergency broadcast system.

", + element = $( content ); + $( "#tooltipped1" ).tooltip({ + content: element, + open: function( event, ui ) { + equal( ui.tooltip.children().html(), content ); + } + }).tooltip( "open" ); +}); + test( "items", function() { expect( 2 ); var event, diff --git a/ui/tooltip.js b/ui/tooltip.js index 7ea1d13ee80..c3b2c19e719 100644 --- a/ui/tooltip.js +++ b/ui/tooltip.js @@ -208,7 +208,8 @@ return $.widget( "ui.tooltip", { that = this, eventType = event ? event.type : null; - if ( typeof contentOption === "string" ) { + if ( typeof contentOption === "string" || contentOption.nodeType || + contentOption.jquery ) { return this._open( event, target, contentOption ); } From 275a8f5fb4100f2e14a184aaa67d0282df024fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rn=20Zaefferer?= Date: Mon, 12 Jan 2015 18:10:45 +0100 Subject: [PATCH 2/2] [tmp]: Fix a11yContent handling, fix tests in IE8 --- tests/unit/tooltip/tooltip_options.js | 8 ++++---- ui/tooltip.js | 10 +++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/tests/unit/tooltip/tooltip_options.js b/tests/unit/tooltip/tooltip_options.js index 9af49b49b47..2d49533f24f 100644 --- a/tests/unit/tooltip/tooltip_options.js +++ b/tests/unit/tooltip/tooltip_options.js @@ -102,24 +102,24 @@ test( "content: string", function() { test( "content: element", function() { expect( 1 ); - var content = "

This is a test of the emergency broadcast system.

", + var content = "

this is a test of the emergency broadcast system.

", element = $( content )[ 0 ]; $( "#tooltipped1" ).tooltip({ content: element, open: function( event, ui ) { - equal( ui.tooltip.children().html(), content ); + equal( ui.tooltip.children().html().toLowerCase(), content ); } }).tooltip( "open" ); }); test( "content: jQuery", function() { expect( 1 ); - var content = "

This is a test of the emergency broadcast system.

", + var content = "

this is a test of the emergency broadcast system.

", element = $( content ); $( "#tooltipped1" ).tooltip({ content: element, open: function( event, ui ) { - equal( ui.tooltip.children().html(), content ); + equal( ui.tooltip.children().html().toLowerCase(), content ); } }).tooltip( "open" ); }); diff --git a/ui/tooltip.js b/ui/tooltip.js index c3b2c19e719..85c64f2a091 100644 --- a/ui/tooltip.js +++ b/ui/tooltip.js @@ -277,13 +277,9 @@ return $.widget( "ui.tooltip", { // JAWS announces deletions even when aria-relevant="additions" // Voiceover will sometimes re-read the entire log region's contents from the beginning this.liveRegion.children().hide(); - if ( content.clone ) { - a11yContent = content.clone(); - a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" ); - } else { - a11yContent = content; - } - $( "
" ).html( a11yContent ).appendTo( this.liveRegion ); + a11yContent = $( "
" ).html( tooltip.find( ".ui-tooltip-content" ).html() ); + a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" ); + a11yContent.appendTo( this.liveRegion ); function position( event ) { positionOption.of = event;