diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-02-22 01:09:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-21 11:09:03 -0600 |
commit | a7e98d70b6f20a80e0f98696e9445ff99546676a (patch) | |
tree | 4feec5e91e1977a87ba9004de23384d278d67d17 /web_src/js/utils | |
parent | 09d737709031b56758f024ef9feabbafd9712cea (diff) | |
download | gitea-a7e98d70b6f20a80e0f98696e9445ff99546676a.tar.gz gitea-a7e98d70b6f20a80e0f98696e9445ff99546676a.zip |
Fix the show/hide methods for string selector (#23042)
At that moment I made a mistake (failed to detect a JS variable type
correctly)
Close #23040
Diffstat (limited to 'web_src/js/utils')
-rw-r--r-- | web_src/js/utils/dom.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/web_src/js/utils/dom.js b/web_src/js/utils/dom.js index 8872a9e4ab..d94d4cb092 100644 --- a/web_src/js/utils/dom.js +++ b/web_src/js/utils/dom.js @@ -19,7 +19,7 @@ function assertShown(el, expectShown) { } function elementsCall(el, func, ...args) { - if (el instanceof String) { + if (typeof el === 'string' || el instanceof String) { el = document.querySelectorAll(el); } if (el instanceof Node) { @@ -34,6 +34,10 @@ function elementsCall(el, func, ...args) { } } +/** + * @param el string (selector), Node, NodeList, HTMLCollection, Array or jQuery + * @param force force=true to show or force=false to hide, undefined to toggle + */ function toggleShown(el, force) { if (force === true) { el.classList.remove('gt-hidden'); |