From b5b0d727740a2e5add2fa0daf0557e1e19a149cb Mon Sep 17 00:00:00 2001 From: Timmy Willison Date: Wed, 6 May 2015 13:30:16 -0700 Subject: 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 --- test/unit/attributes.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test') 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( "" ).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" ); + }); +}); -- cgit v1.2.3