All files / app/assets/javascripts/pages/projects/shared/permissions external.js

50% Statements 4/8
25% Branches 1/4
33.33% Functions 1/3
57.14% Lines 4/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 191x                         1x 1x   1x    
const selectorCache = [];
 
// workaround since we don't have a polyfill for classList.toggle 2nd parameter
export function toggleHiddenClass(element, hidden) {
  if (hidden) {
    element.classList.add('hidden');
  } else {
    element.classList.remove('hidden');
  }
}
 
// hide external feature-specific settings when a given feature is disabled
export function toggleHiddenClassBySelector(selector, hidden) {
  Eif (!selectorCache[selector]) {
    selectorCache[selector] = document.querySelectorAll(selector);
  }
  selectorCache[selector].forEach((elm) => toggleHiddenClass(elm, hidden));
}