code: function applyShadyCSS(template, tagName) {
    if (!tagName) return template;
  
    return shadyCSS((shady) => {
      let map = preparedTemplates.get(template);
      if (!map) {
        map = new Map();
        preparedTemplates.set(template, map);
      }
  
      let clone = map.get(tagName);
  
      if (!clone) {
        clone = document.createElement('template');
        clone.content.appendChild(template.content.cloneNode(true));
  
        map.set(tagName, clone);
  
        const styles = clone.content.querySelectorAll('style');
  
        Array.from(styles).forEach((style) => {
          const count = style.childNodes.length + 1;
          for (let i = 0; i < count; i += 1) {
            style.parentNode.insertBefore(document.createTextNode(getPlaceholder()), style);
          }
        });
  
        shady.prepareTemplate(clone, tagName.toLowerCase());
      }
      return clone;
    }, template);
  }
docs: /* istanbul ignore next