|
1 | | -const originalStyles = new WeakMap< |
| 1 | +const elementStyles = new WeakMap< |
2 | 2 | HTMLElement, |
3 | 3 | { |
4 | 4 | visibility?: string; |
5 | 5 | transition?: string; |
6 | 6 | animation?: string; |
7 | 7 | } |
8 | 8 | >(); |
| 9 | +/** |
| 10 | + * Clears the visibility, transition, and animation styles of an element and stores the original values |
| 11 | + * @param element - The element to clear the styles from |
| 12 | + * VB-277 Fix: Clear visibility, transition, and animation styles of an element |
| 13 | + */ |
9 | 14 |
|
10 | | -export function clearVisibelityStyles(element: HTMLElement) { |
| 15 | +export function clearVisibilityStyles(element: HTMLElement) { |
11 | 16 | const originalStyleValues = { |
12 | 17 | visibility: element.style.visibility, |
13 | 18 | transition: element.style.transition, |
14 | 19 | animation: element.style.animation, |
15 | 20 | }; |
16 | 21 |
|
17 | | - originalStyles.set(element, originalStyleValues); |
| 22 | + elementStyles.set(element, originalStyleValues); |
18 | 23 |
|
19 | 24 | element.style.visibility = "hidden"; |
20 | 25 | element.style.transition = "none"; |
21 | 26 | element.style.animation = "none"; |
22 | 27 | } |
23 | 28 |
|
24 | | -export function restoreVisibelityStyles(element: HTMLElement) { |
25 | | - const storedStyles = originalStyles.get(element); |
| 29 | +export function restoreVisibilityStyles(element: HTMLElement) { |
| 30 | + const storedStyles = elementStyles.get(element); |
26 | 31 |
|
27 | 32 | if (storedStyles) { |
28 | 33 | element.style.visibility = storedStyles.visibility || ""; |
29 | 34 | element.style.transition = storedStyles.transition || ""; |
30 | 35 | element.style.animation = storedStyles.animation || ""; |
31 | 36 |
|
32 | | - originalStyles.delete(element); |
| 37 | + elementStyles.delete(element); |
33 | 38 | } |
34 | 39 | } |
0 commit comments