function buildQueryCss()

in projects/libs/flex-layout/core/match-media/match-media.ts [159:188]


function buildQueryCss(mediaQueries: string[], _document: Document) {
  const list = mediaQueries.filter(it => !ALL_STYLES[it]);
  if (list.length > 0) {
    const query = list.join(', ');

    try {
      const styleEl = _document.createElement('style');

      styleEl.setAttribute('type', 'text/css');
      if (!(styleEl as any).styleSheet) {
        const cssText = `
/*
  @angular/flex-layout - workaround for possible browser quirk with mediaQuery listeners
  see http://bit.ly/2sd4HMP
*/
@media ${query} {.fx-query-test{ }}
`;
        styleEl.appendChild(_document.createTextNode(cssText));
      }

      _document.head!.appendChild(styleEl);

      // Store in private global registry
      list.forEach(mq => ALL_STYLES[mq] = styleEl);

    } catch (e) {
      console.error(e);
    }
  }
}