Skip to content

Commit 026167f

Browse files
authored
Remove assertion debug code for show/hide refactoring (#23576) (#23868)
Backport #23576 by @wxiaoguang When doing the refactoring: * #22950 I added some debug mode code (assertShown) to help to catch bugs, it did catch some bugs like: * #23074 If it has been proved that there is no more bugs, this assertion could be removed easily and clearly. Feel free to decide when to remove it (feel free to convert it from Draft to Ready for Review).
1 parent 8abfbe2 commit 026167f

File tree

1 file changed

+0
-26
lines changed

1 file changed

+0
-26
lines changed

web_src/js/utils/dom.js

-26
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
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-
211
function elementsCall(el, func, ...args) {
222
if (typeof el === 'string' || el instanceof String) {
233
el = document.querySelectorAll(el);
@@ -41,16 +21,10 @@ function elementsCall(el, func, ...args) {
4121
function toggleShown(el, force) {
4222
if (force === true) {
4323
el.classList.remove('gt-hidden');
44-
assertShown(el, true);
4524
} else if (force === false) {
4625
el.classList.add('gt-hidden');
47-
assertShown(el, false);
4826
} else if (force === undefined) {
49-
const wasShown = window.config.runModeIsProd ? undefined : isShown(el);
5027
el.classList.toggle('gt-hidden');
51-
if (wasShown !== undefined) {
52-
assertShown(el, !wasShown);
53-
}
5428
} else {
5529
throw new Error('invalid force argument');
5630
}

0 commit comments

Comments
 (0)