From b0982b3e6d83a56a98c9c8318c9b3c646d56c2b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski-Owczarek?= Date: Thu, 13 May 2021 15:30:07 +0200 Subject: [PATCH 1/2] removeClass: Separate the signature with no parameters That signature removes all classes which wasn't that clear from the original signatures until one read the description. --- entries/removeClass.xml | 370 +++++++++++++++++++++------------------- 1 file changed, 195 insertions(+), 175 deletions(-) diff --git a/entries/removeClass.xml b/entries/removeClass.xml index c2daa31c..d4096380 100644 --- a/entries/removeClass.xml +++ b/entries/removeClass.xml @@ -1,177 +1,197 @@ - - .removeClass() - - 1.0 - - One or more space-separated classes to be removed from the class attribute of each matched element. - - - - 3.3 - - An array of classes to be removed from the class attribute of each matched element. - - - - 1.4 - - - - - A function returning one or more space-separated class names to be removed. Receives the index position of the element in the set and the old class value as arguments. - - - - 3.3 - - - - - - A function returning one or more space-separated class names or an array of class names to be removed. Receives the index position of the element in the set and the old class value as arguments. - - + Remove a single class, multiple classes, or all classes from each element in the set of matched elements. - -

If a class name is included as a parameter, then only that class will be removed from the set of matched elements. If no classes are specified in the parameter, all classes will be removed.

-

Before jQuery version 1.12/2.2, the .removeClass() 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. This means that when the class attribute was updated and the last class name was removed, the browser might have set the attribute's value to an empty string instead of removing the attribute completely. 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, .removeClass() can be used on XML or SVG documents.

-

More than one class may be removed at a time, separated by a space, from the set of matched elements, like so:

-

-$( "p" ).removeClass( "myClass yourClass" )
-    
-

This method is often used with .addClass() to switch elements' classes from one to another, like so:

-

-$( "p" ).removeClass( "myClass noClass" ).addClass( "yourClass" );
-    
-

Here, the myClass and noClass classes are removed from all paragraphs, while yourClass is added.

-

To replace all existing classes with another class, we can use .attr( "class", "newClass" ) instead.

-

As of jQuery 1.4, the .removeClass() method allows us to indicate the class to be removed by passing in a function.

-

-$( "li" ).last().removeClass(function() {
-  return $( this ).prev().attr( "class" );
-});
-    
-

This example removes the class name of the penultimate <li> from the last <li>.

-
- - Remove the class 'blue' from the matched elements. - - - Hello

-

and

-

then

-

Goodbye

-]]> -
- - Remove the class 'blue' and 'under' from the matched elements. - - - Hello

-

and

-

then

-

Goodbye

-]]> -
- - Remove the class 'blue' and 'under' from the matched elements (3.3+ syntax). - - - Hello

-

and

-

then

-

Goodbye

-]]> -
- - Remove all the classes from the matched elements. - - - Hello

-

and

-

then

-

Goodbye

-]]> -
- - - - - - - -
+ + .removeClass( classes ) + + 1.0 + + One or more space-separated classes to be removed from the class attribute of each matched element. + + + + 3.3 + + An array of classes to be removed from the class attribute of each matched element. + + + + 1.4 + + + + + A function returning one or more space-separated class names to be removed. Receives the index position of the element in the set and the old class value as arguments. + + + + 3.3 + + + + + + A function returning one or more space-separated class names or an array of class names to be removed. Receives the index position of the element in the set and the old class value as arguments. + + + Remove a single class or multiple classes from each element in the set of matched elements. + +

If a class name is included as a parameter, then only that class will be removed from the set of matched elements. If no classes are specified in the parameter, all classes will be removed.

+

Before jQuery version 1.12/2.2, the .removeClass() 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. This means that when the class attribute was updated and the last class name was removed, the browser might have set the attribute's value to an empty string instead of removing the attribute completely. 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, .removeClass() can be used on XML or SVG documents.

+

More than one class may be removed at a time, separated by a space, from the set of matched elements, like so:

+

+  $( "p" ).removeClass( "myClass yourClass" )
+      
+

This method is often used with .addClass() to switch elements' classes from one to another, like so:

+

+  $( "p" ).removeClass( "myClass noClass" ).addClass( "yourClass" );
+      
+

Here, the myClass and noClass classes are removed from all paragraphs, while yourClass is added.

+

To replace all existing classes with another class, we can use .attr( "class", "newClass" ) instead.

+

As of jQuery 1.4, the .removeClass() method allows us to indicate the class to be removed by passing in a function.

+

+  $( "li" ).last().removeClass(function() {
+    return $( this ).prev().attr( "class" );
+  });
+      
+

This example removes the class name of the penultimate <li> from the last <li>.

+
+ + Remove the class 'blue' from the matched elements. + + + Hello

+

and

+

then

+

Goodbye

+ ]]> +
+ + Remove the class 'blue' and 'under' from the matched elements. + + + Hello

+

and

+

then

+

Goodbye

+ ]]> +
+ + Remove the class 'blue' and 'under' from the matched elements (3.3+ syntax). + + + Hello

+

and

+

then

+

Goodbye

+ ]]> +
+ + + + + + + +
+ + + .removeClass() + + 1.0 + + Remove all classes from each matched element. + +

Before jQuery version 1.12/2.2, the .removeClass() 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. This means that when the class attribute was updated and the last class name was removed, the browser might have set the attribute's value to an empty string instead of removing the attribute completely. 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, .removeClass() can be used on XML or SVG documents.

+
+ + Remove all the classes from the matched elements. + + + Hello

+

and

+

then

+

Goodbye

+ ]]> +
+ + + + + +
+ From a263dbbe7135ce0396310811281d79fc905c4584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski-Owczarek?= Date: Mon, 17 May 2021 18:29:31 +0200 Subject: [PATCH 2/2] fixup! removeClass: Separate the signature with no parameters --- entries/removeClass.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/entries/removeClass.xml b/entries/removeClass.xml index d4096380..2edb382d 100644 --- a/entries/removeClass.xml +++ b/entries/removeClass.xml @@ -36,7 +36,6 @@ Remove a single class or multiple classes from each element in the set of matched elements. -

If a class name is included as a parameter, then only that class will be removed from the set of matched elements. If no classes are specified in the parameter, all classes will be removed.

Before jQuery version 1.12/2.2, the .removeClass() 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. This means that when the class attribute was updated and the last class name was removed, the browser might have set the attribute's value to an empty string instead of removing the attribute completely. 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, .removeClass() can be used on XML or SVG documents.

More than one class may be removed at a time, separated by a space, from the set of matched elements, like so: