1
- function getComputedStyleProperty ( el , prop ) {
2
- const cs = el ? window . getComputedStyle ( el ) : null ;
3
- return cs ? cs [ prop ] : null ;
4
- }
5
-
6
- function isShown ( el ) {
7
- return getComputedStyleProperty ( el , 'display' ) !== 'none' ;
8
- }
9
-
10
- function assertShown ( el , expectShown ) {
11
- if ( window . config . runModeIsProd ) return ;
12
-
13
- // to help developers to catch display bugs, this assertion can be removed after next release cycle or if it has been proved that there is no bug.
14
- if ( expectShown && ! isShown ( el ) ) {
15
- throw new Error ( 'element is hidden but should be shown' ) ;
16
- } else if ( ! expectShown && isShown ( el ) ) {
17
- throw new Error ( 'element is shown but should be hidden' ) ;
18
- }
19
- }
20
-
21
1
function elementsCall ( el , func , ...args ) {
22
2
if ( typeof el === 'string' || el instanceof String ) {
23
3
el = document . querySelectorAll ( el ) ;
@@ -41,16 +21,10 @@ function elementsCall(el, func, ...args) {
41
21
function toggleShown ( el , force ) {
42
22
if ( force === true ) {
43
23
el . classList . remove ( 'gt-hidden' ) ;
44
- assertShown ( el , true ) ;
45
24
} else if ( force === false ) {
46
25
el . classList . add ( 'gt-hidden' ) ;
47
- assertShown ( el , false ) ;
48
26
} else if ( force === undefined ) {
49
- const wasShown = window . config . runModeIsProd ? undefined : isShown ( el ) ;
50
27
el . classList . toggle ( 'gt-hidden' ) ;
51
- if ( wasShown !== undefined ) {
52
- assertShown ( el , ! wasShown ) ;
53
- }
54
28
} else {
55
29
throw new Error ( 'invalid force argument' ) ;
56
30
}
0 commit comments