code: function scopeStylesToNode (domNode, cssText, scope) {
    let styleNode = domNode.querySelector(`#${scope}`)
    const attr = scope.toLowerCase()
  
    if (!cssText) {
      if (styleNode) {
        if (!styleNode.scoped) {
          removeScopeFromDomNode(domNode, attr)
        }
        domNode.removeChild(styleNode)
      }
    } else {
      const shouldInsertNode = !styleNode
      let scopedCSS = cssText
  
      if (shouldInsertNode) {
        styleNode = document.createElement('style')
        styleNode.setAttribute('scoped', true)
        styleNode.setAttribute('type', 'text/css')
        styleNode.id = scope
      }
  
      if (!styleNode.scoped) { // if scoped styles are not supported
        addScopeToDomNode(domNode, attr)
        scopedCSS = scopeCssText(scopedCSS, `[${attr}]`)
      }
  
      if (shouldInsertNode) {
        domNode.insertBefore(styleNode, domNode.firstChild)
      }
  
      if ('textContent' in styleNode) {
        styleNode.textContent = scopedCSS
      } else {
        styleNode.styleSheet.cssText = scopedCSS
      }
    }
  }
docs: ---
  category: utilities/themes
  ---
  Scopes the styles in a CSS string to a DOM node
  to polyfill CSS variables for [themeable](#themeable) components.
  @module scopeStylesToNode
  @param {DOMNode} domNode
  @param {String} cssText
  @param {String} scope a unique identifier to use to scope the styles. Applied as a custom html attribute.