How to use the fela-utils.getStyleNode function in fela-utils

To help you get started, we’ve selected a few fela-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github robinweser / fela / packages / fela-dom / src / initStyleNodes.js View on Github external
function initNode(
  styleNodes: Object,
  baseNode: Object,
  css: string,
  type: string,
  media: string = ''
): void {
  const node = getStyleNode(styleNodes, baseNode, type, media)
  // in case that there is a node coming from server already
  // but rules are not matchnig
  if (node.textContent !== css) {
    node.textContent = css
  }
}
github robinweser / fela / packages / fela-dom / src / DOMInterface.js View on Github external
return function changeSubscription(change) {
    if (change.type === CLEAR_TYPE) {
      for (const node in renderer.styleNodes) {
        renderer.styleNodes[node].textContent = ''
      }

      return
    }

    const styleNode = getStyleNode(
      renderer.styleNodes,
      baseNode,
      change.type,
      change.media
    )

    if (change.type === RULE_TYPE) {
      // only use insertRule in production as browser devtools might have
      // weird behavior if used together with insertRule at runtime
      if (process.env.NODE_ENV !== 'production') {
        if (change.media) {
          styleNode.textContent = renderer.mediaRules[change.media]
        } else {
          styleNode.textContent = renderer.rules
        }
      } else {