mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 17:01:08 -04:00
parent
a0b444d6c4
commit
0e2da630d5
3 changed files with 12 additions and 0 deletions
|
@ -21,6 +21,7 @@ _This release is scheduled to be released on 2024-01-01._
|
|||
|
||||
- Fix the option eventClass on customEvents.
|
||||
- Fix yr API version in locationforecast call (#3227)
|
||||
- Fix cloneObject() function to respect RegExp (#3237)
|
||||
|
||||
## [2.25.0] - 2023-10-01
|
||||
|
||||
|
|
|
@ -90,6 +90,10 @@ function cloneObject(obj) {
|
|||
return obj;
|
||||
}
|
||||
|
||||
if (obj.constructor.name === "RegExp") {
|
||||
return new RegExp(obj);
|
||||
}
|
||||
|
||||
const temp = obj.constructor(); // give temp the original obj's constructor
|
||||
for (const key in obj) {
|
||||
temp[key] = cloneObject(obj[key]);
|
||||
|
|
|
@ -49,6 +49,13 @@ describe("File js/class", () => {
|
|||
expect(obj).toBe(expected);
|
||||
});
|
||||
|
||||
it("should clone regex", () => {
|
||||
const expected = /.*Magic/;
|
||||
const obj = clone(expected);
|
||||
expect(obj).toEqual(expected);
|
||||
expect(expected === obj).toBe(false);
|
||||
});
|
||||
|
||||
it("should clone undefined", () => {
|
||||
const expected = undefined;
|
||||
const obj = clone(expected);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue