aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTimmy Willison <timmywillisn@gmail.com>2015-05-06 13:30:16 -0700
committerTimmy Willison <timmywillisn@gmail.com>2015-05-12 10:13:46 -0400
commit20aaed367f993f3c2aa204183d82d0d73efa114f (patch)
tree8cb2c031778c9a867bc5b80dc0893316b3e66204 /test
parent56bb677725b21415905e5c3eeb1e05be4480e780 (diff)
downloadjquery-20aaed367f993f3c2aa204183d82d0d73efa114f.tar.gz
jquery-20aaed367f993f3c2aa204183d82d0d73efa114f.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.js28
1 files changed, 28 insertions, 0 deletions
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( "<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" );
+ });
+});