aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-04-02 12:03:00 +0800
committerGitHub <noreply@github.com>2023-04-02 00:03:00 -0400
commitfcb9ef8788da02c13ee7201b5b8bce216da3f0d7 (patch)
tree4175c038c32eb35a1a2f664c12f3dafd2f65b2a0
parentc9d7c83e30c6147ddd88358e448a52e79dab9986 (diff)
downloadgitea-fcb9ef8788da02c13ee7201b5b8bce216da3f0d7.tar.gz
gitea-fcb9ef8788da02c13ee7201b5b8bce216da3f0d7.zip
Remove assertion debug code for show/hide refactoring (#23576)
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). cc: @silverwind
-rw-r--r--web_src/js/utils/dom.js26
1 files changed, 0 insertions, 26 deletions
diff --git a/web_src/js/utils/dom.js b/web_src/js/utils/dom.js
index 80c9f01cf2..c160d37f6c 100644
--- a/web_src/js/utils/dom.js
+++ b/web_src/js/utils/dom.js
@@ -1,23 +1,3 @@
-function getComputedStyleProperty(el, prop) {
- const cs = el ? window.getComputedStyle(el) : null;
- return cs ? cs[prop] : null;
-}
-
-function isShown(el) {
- return getComputedStyleProperty(el, 'display') !== 'none';
-}
-
-function assertShown(el, expectShown) {
- if (window.config.runModeIsProd) return;
-
- // 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.
- if (expectShown && !isShown(el)) {
- throw new Error('element is hidden but should be shown');
- } else if (!expectShown && isShown(el)) {
- throw new Error('element is shown but should be hidden');
- }
-}
-
function elementsCall(el, func, ...args) {
if (typeof el === 'string' || el instanceof String) {
el = document.querySelectorAll(el);
@@ -41,16 +21,10 @@ function elementsCall(el, func, ...args) {
function toggleShown(el, force) {
if (force === true) {
el.classList.remove('gt-hidden');
- assertShown(el, true);
} else if (force === false) {
el.classList.add('gt-hidden');
- assertShown(el, false);
} else if (force === undefined) {
- const wasShown = window.config.runModeIsProd ? undefined : isShown(el);
el.classList.toggle('gt-hidden');
- if (wasShown !== undefined) {
- assertShown(el, !wasShown);
- }
} else {
throw new Error('invalid force argument');
}