Skip to content

Commit a46c180

Browse files
authored
addClass:removeClass:toggleClass: Update function signatures
From jQuery 3.3.0[1], if using a function as a argument for `.addClass`, `.removeClass` and `.toggleClass`, the function is allowed to return an `Array`. However, this was not reflected in the return types. This change documents that new signature. Closes jquerygh-1183 [1] https://blog.jquery.com/2018/01/19/jquery-3-3-0-a-fragrant-bouquet-of-deprecations-and-is-that-a-new-feature/
1 parent e5f5d6c commit a46c180

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

entries/addClass.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,22 @@
1616
<signature>
1717
<added>1.4</added>
1818
<argument name="function" type="Function">
19-
<desc>A function returning one or more space-separated classes or an array of classes to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, <code>this</code> refers to the current element in the set.</desc>
19+
<desc>A function returning one or more space-separated class names to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, <code>this</code> refers to the current element in the set.</desc>
2020
<argument name="index" type="Integer" />
2121
<argument name="currentClassName" type="String" />
2222
<return type="String"/>
2323
</argument>
2424
</signature>
25+
<signature>
26+
<added>3.3</added>
27+
<argument name="function" type="Function">
28+
<desc>A function returning one or more space-separated class names or an array of class names to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, <code>this</code> refers to the current element in the set.</desc>
29+
<argument name="index" type="Integer" />
30+
<argument name="currentClassName" type="String" />
31+
<return type="String"/>
32+
<return type="Array"/>
33+
</argument>
34+
</signature>
2535
<desc>Adds the specified class(es) to each element in the set of matched elements.</desc>
2636
<longdesc>
2737
<p>It's important to note that this method does not replace a class. It simply adds the class, appending it to any which may already be assigned to the elements.</p>

entries/removeClass.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,17 @@
1919
<argument name="index" type="Integer" />
2020
<argument name="className" type="String" />
2121
<return type="String" />
22-
<desc>A function returning one or more space-separated classes or an array of classes to be removed. Receives the index position of the element in the set and the old class value as arguments.</desc>
22+
<desc>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.</desc>
23+
</argument>
24+
</signature>
25+
<signature>
26+
<added>3.3</added>
27+
<argument name="function" type="Function">
28+
<argument name="index" type="Integer" />
29+
<argument name="className" type="String" />
30+
<return type="String" />
31+
<return type="Array" />
32+
<desc>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.</desc>
2333
</argument>
2434
</signature>
2535
<desc>Remove a single class, multiple classes, or all classes from each element in the set of matched elements.</desc>

entries/toggleClass.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,21 @@
3939
<argument name="className" type="String" />
4040
<argument name="state" type="Boolean" />
4141
<return type="String" />
42-
<desc>A function that returns one or more space-separated classes or an array of classes to be toggled in the class attribute of each element in the matched set. Receives the index position of the element in the set, the old class value, and the state as arguments.</desc>
42+
<desc>A function returning one or more space-separated class names to be toggled in the class attribute of each element in the matched set. Receives the index position of the element in the set, the old class value, and the state as arguments.</desc>
43+
</argument>
44+
<argument name="state" optional="true" type="Boolean">
45+
<desc>A boolean value to determine whether the class should be added or removed.</desc>
46+
</argument>
47+
</signature>
48+
<signature>
49+
<added>3.3</added>
50+
<argument name="function" type="Function">
51+
<argument name="index" type="Integer" />
52+
<argument name="className" type="String" />
53+
<argument name="state" type="Boolean" />
54+
<return type="String" />
55+
<return type="Array" />
56+
<desc>A function returning one or more space-separated class names or an array of class names to be toggled in the class attribute of each element in the matched set. Receives the index position of the element in the set, the old class value, and the state as arguments.</desc>
4357
</argument>
4458
<argument name="state" optional="true" type="Boolean">
4559
<desc>A boolean value to determine whether the class should be added or removed.</desc>

0 commit comments

Comments
 (0)