Skip to content

Commit

Permalink
Fix the show/hide methods for string selector (#23042)
Browse files Browse the repository at this point in the history
At that moment I made a mistake (failed to detect a JS variable type
correctly)

Close #23040
  • Loading branch information
wxiaoguang authored Feb 21, 2023
1 parent 09d7377 commit a7e98d7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion web_src/js/utils/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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');
Expand Down

0 comments on commit a7e98d7

Please sign in to comment.