diff options
author | Timmy Willison <timmywillisn@gmail.com> | 2015-05-06 13:30:16 -0700 |
---|---|---|
committer | Timmy Willison <timmywillisn@gmail.com> | 2015-05-12 10:24:42 -0400 |
commit | b5b0d727740a2e5add2fa0daf0557e1e19a149cb (patch) | |
tree | a2316c685738a4901df967dffe335006c491af25 /test | |
parent | cbd51c50b3b38574ba86093df34f88eaae5d294f (diff) | |
download | jquery-b5b0d727740a2e5add2fa0daf0557e1e19a149cb.tar.gz jquery-b5b0d727740a2e5add2fa0daf0557e1e19a149cb.zip |
Attributes: add SVG class manipulation
- Note: support for SVG is limited in jQuery,
but this is one area where the cost vs benefit ratio
was acceptable.
Fixes gh-2199
Close gh-2268
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/attributes.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/unit/attributes.js b/test/unit/attributes.js index 1e9c2fee2..022d4a8b3 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -1476,3 +1476,31 @@ test( "Insignificant white space returned for $(option).val() (#14858)", functio val = jQuery( "<option> test </option>" ).val(); equal( val.length, 4, "insignificant white-space returned for value" ); }); + +test( "SVG class manipulation (gh-2199)", function() { + expect( 12 ); + + function createSVGElement( nodeName ) { + return document.createElementNS( "http://www.w3.org/2000/svg", nodeName ); + } + + jQuery.each([ + "svg", + "rect", + "g" + ], function() { + var elem = jQuery( createSVGElement( this ) ); + + elem.addClass( "awesome" ); + ok( elem.hasClass( "awesome" ), "SVG element (" + this + ") has added class" ); + + elem.removeClass( "awesome" ); + ok( !elem.hasClass( "awesome" ), "SVG element (" + this + ") removes the class" ); + + elem.toggleClass( "awesome" ); + ok( elem.hasClass( "awesome" ), "SVG element (" + this + ") toggles the class on" ); + + elem.toggleClass( "awesome" ); + ok( !elem.hasClass( "awesome" ), "SVG element (" + this + ") toggles the class off" ); + }); +}); |