From 5b90d81484b50366ca27510ba032117b606060b1 Mon Sep 17 00:00:00 2001 From: Aurelio De Rosa Date: Thu, 11 Feb 2016 00:20:54 +0000 Subject: [PATCH] Noted support of SVG documents for class methods Fixes gh-885 Closes gh-886 --- entries/hasClass.xml | 1 + entries/toggleClass.xml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/entries/hasClass.xml b/entries/hasClass.xml index 37b52f79..ddf5d893 100644 --- a/entries/hasClass.xml +++ b/entries/hasClass.xml @@ -25,6 +25,7 @@ $( "#mydiv" ).hasClass( "bar" )

 $( "#mydiv" ).hasClass( "quux" )
     
+

As of jQuery 1.12/2.2, this method supports XML documents, including SVG.

Looks for the paragraph that contains 'selected' as a class. diff --git a/entries/toggleClass.xml b/entries/toggleClass.xml index 1d034d86..f14cb8ed 100644 --- a/entries/toggleClass.xml +++ b/entries/toggleClass.xml @@ -37,6 +37,8 @@ Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the state argument. +

Before jQuery version 1.12/2.2, the .toggleClass() method manipulated the className property of the selected elements, not the class attribute. Once the property was changed, it was the browser that updated the attribute accordingly. An implication of this behavior was that this method only worked for documents with HTML DOM semantics (e.g., not pure XML documents).

+

As of jQuery 1.12/2.2, this behavior is changed to improve the support for XML documents, including SVG. Starting from this version, the class attribute is used instead. So, .toggleClass() can be used on XML or SVG documents.

This method takes one or more class names as its parameter. In the first version, if an element in the matched set of elements already has the class, then it is removed; if an element does not have the class, then it is added. For example, we can apply .toggleClass() to a simple <div>:


 <div class="tumble">Some text.</div>