All files / app/assets/javascripts/behaviors load_startup_css.js

100% Statements 4/4
100% Branches 0/0
100% Functions 3/3
100% Lines 4/4

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 161x         2x     2x   4x          
export const loadStartupCSS = () => {
  // We need to fallback to dispatching `load` in case our event listener was added too late
  // or the browser environment doesn't load media=print.
  // Do this on `window.load` so that the default deferred behavior takes precedence.
  // https://gitlab.com/gitlab-org/gitlab/-/issues/239357
  window.addEventListener(
    'load',
    () => {
      document
        .querySelectorAll('link[media=print]')
        .forEach((x) => x.dispatchEvent(new Event('load')));
    },
    { once: true },
  );
};