happy-dom 2.26.0 → 2.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of happy-dom might be problematic. Click here for more details.
@@ -29,4 +29,12 @@ export default class ClassList {
|
|
29
29
|
* @returns TRUE if it contains.
|
30
30
|
*/
|
31
31
|
contains(className: string): boolean;
|
32
|
+
/**
|
33
|
+
* Toggle a class name.
|
34
|
+
*
|
35
|
+
* @param className A string representing the class name you want to toggle.
|
36
|
+
* @param force If included, turns the toggle into a one way-only operation. If set to `false`, then class name will only be removed, but not added. If set to `true`, then class name will only be added, but not removed.
|
37
|
+
* @returns A boolean value, `true` or `false`, indicating whether class name is in the list after the call or not.
|
38
|
+
*/
|
39
|
+
toggle(className: string, force?: boolean): boolean;
|
32
40
|
}
|
@@ -71,6 +71,28 @@ var ClassList = /** @class */ (function () {
|
|
71
71
|
var list = attr ? attr.split(' ') : [];
|
72
72
|
return list.includes(className);
|
73
73
|
};
|
74
|
+
/**
|
75
|
+
* Toggle a class name.
|
76
|
+
*
|
77
|
+
* @param className A string representing the class name you want to toggle.
|
78
|
+
* @param force If included, turns the toggle into a one way-only operation. If set to `false`, then class name will only be removed, but not added. If set to `true`, then class name will only be added, but not removed.
|
79
|
+
* @returns A boolean value, `true` or `false`, indicating whether class name is in the list after the call or not.
|
80
|
+
*/
|
81
|
+
ClassList.prototype.toggle = function (className, force) {
|
82
|
+
var shouldAdd;
|
83
|
+
if (force !== undefined) {
|
84
|
+
shouldAdd = force;
|
85
|
+
}
|
86
|
+
else {
|
87
|
+
shouldAdd = !this.contains(className);
|
88
|
+
}
|
89
|
+
if (shouldAdd) {
|
90
|
+
this.add(className);
|
91
|
+
return true;
|
92
|
+
}
|
93
|
+
this.remove(className);
|
94
|
+
return false;
|
95
|
+
};
|
74
96
|
return ClassList;
|
75
97
|
}());
|
76
98
|
exports.default = ClassList;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":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G,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACtD,IAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;OAMG;IACI,0BAAM,GAAb,UAAc,SAAiB,EAAE,KAAe;QAC/C,IAAI,SAAkB,CAAC;QACvB,IAAI,KAAK,KAAK,SAAS,EAAE;YACxB,SAAS,GAAG,KAAK,CAAC;SAClB;aAAM;YACN,SAAS,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;SACtC;QAED,IAAI,SAAS,EAAE;YACd,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACpB,OAAO,IAAI,CAAC;SACZ;QAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACvB,OAAO,KAAK,CAAC;IACd,CAAC;IACF,gBAAC;AAAD,CAAC,AArFD,IAqFC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "happy-dom",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.27.0",
|
4
4
|
"license": "MIT",
|
5
5
|
"homepage": "https://github.com/capricorn86/happy-dom",
|
6
6
|
"repository": "https://github.com/capricorn86/happy-dom",
|
@@ -74,5 +74,5 @@
|
|
74
74
|
"ts-jest": "^26.5.6",
|
75
75
|
"typescript": "^4.2.4"
|
76
76
|
},
|
77
|
-
"gitHead": "
|
77
|
+
"gitHead": "f2216292372dfd2f4afccf53a35c21e31ba82df9"
|
78
78
|
}
|
@@ -65,4 +65,28 @@ export default class ClassList {
|
|
65
65
|
const list = attr ? attr.split(' ') : [];
|
66
66
|
return list.includes(className);
|
67
67
|
}
|
68
|
+
|
69
|
+
/**
|
70
|
+
* Toggle a class name.
|
71
|
+
*
|
72
|
+
* @param className A string representing the class name you want to toggle.
|
73
|
+
* @param force If included, turns the toggle into a one way-only operation. If set to `false`, then class name will only be removed, but not added. If set to `true`, then class name will only be added, but not removed.
|
74
|
+
* @returns A boolean value, `true` or `false`, indicating whether class name is in the list after the call or not.
|
75
|
+
*/
|
76
|
+
public toggle(className: string, force?: boolean): boolean {
|
77
|
+
let shouldAdd: boolean;
|
78
|
+
if (force !== undefined) {
|
79
|
+
shouldAdd = force;
|
80
|
+
} else {
|
81
|
+
shouldAdd = !this.contains(className);
|
82
|
+
}
|
83
|
+
|
84
|
+
if (shouldAdd) {
|
85
|
+
this.add(className);
|
86
|
+
return true;
|
87
|
+
}
|
88
|
+
|
89
|
+
this.remove(className);
|
90
|
+
return false;
|
91
|
+
}
|
68
92
|
}
|