From 20aaed367f993f3c2aa204183d82d0d73efa114f 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 c1f773718..526cfc99d 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -1478,3 +1478,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