diff options
author | Daniel DeGroff <djdegroff@gmail.com> | 2013-12-02 22:03:55 -0600 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2014-01-06 16:10:02 +0100 |
commit | af85dfcafb32b7503392ca834eaa9d3162d54b28 (patch) | |
tree | 9f01beeb1794a9df54d38a64bf00b4b23f7a5d7f /tests/unit/tooltip/tooltip_methods.js | |
parent | b9e438d07c370ac2d4b198048feb6b6922469f70 (diff) | |
download | jquery-ui-af85dfcafb32b7503392ca834eaa9d3162d54b28.tar.gz jquery-ui-af85dfcafb32b7503392ca834eaa9d3162d54b28.zip |
Tooltip: On close and destroy only set title if empty or undefined
Ticket #8925 states that changes to the title attribute while the
tooltip is open are lost on tooltip close.
In the close and destroy functions, the title attribute is always
written if a value was stored in the element on open. It is possible
the attribute has changed and restoring the initial value may overwrite
the current value.
If the value is empty or undefined as set in open, do not set the title
attribute.
This fix has the limitation that if the user removed the title
attribute or set the value to an empty string the original title value
would be restored on close and destroy.
Fixes #8925
Diffstat (limited to 'tests/unit/tooltip/tooltip_methods.js')
-rw-r--r-- | tests/unit/tooltip/tooltip_methods.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js index a557ff943..ead360bf3 100644 --- a/tests/unit/tooltip/tooltip_methods.js +++ b/tests/unit/tooltip/tooltip_methods.js @@ -96,4 +96,39 @@ test( "widget", function() { strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" ); }); +test( "preserve changes to title attributes on close and destroy", function() { + expect( 6 ); + var element = $( "#tooltipped1" ), + changed = "changed title text", + original = "original title text", + tests = []; + + // 1. Changes to title attribute are preserved on close() + tests[ 0 ] = { title: changed, expected: changed, method: "close" }; + // 2. Changes to title attribute are preserved on destroy() + tests[ 1 ] = { title: changed, expected: changed , method: "destroy" }; + // 3. Changes to title attribute are NOT preserved when set to empty string on close() + tests[ 2 ] = { title: "", expected: original, method: "close" }; + // 4. Changes to title attribute are NOT preserved when set to empty string on destroy() + tests[ 3 ] = { title: "", expected: original, method: "destroy" }; + // 5. Changes to title attribute NOT preserved when attribute has been removed on close() + tests[ 4 ] = { expected: original, method: "close" }; + // 6. Changes to title attribute NOT preserved when attribute has been removed on destroy() + tests[ 5 ] = { expected: original, method: "destroy" }; + + $.each( tests, function( index, test ) { + + element.attr( "title", original ).tooltip() + .tooltip( "open", $.Event( "mouseover", { target: element[ 0 ] } ) ); + if ( test.title ) { + element.attr( "title", test.title ); + } else { + element.removeAttr( "title" ); + } + element.tooltip( test.method ); + equal( $( "#tooltipped1" ).attr( "title" ), test.expected ); + + } ); +}); + }( jQuery ) ); |