MCPcopy Create free account
hub / github.com/TanStack/query / setupStyleSheet

Function setupStyleSheet

packages/query-devtools/src/utils.tsx:392–407  ·  view source on GitHub ↗
(nonce?: string, target?: ShadowRoot)

Source from the content-addressed store, hash-verified

390 * @param target - The shadow root to add the style tag to, instead of `document.head`.
391 */
392export const setupStyleSheet = (nonce?: string, target?: ShadowRoot) => {
393 if (!nonce)
394 return // Goober reads window.__nonce__ every time it creates or accesses its style
395 // element (el.nonce = window.__nonce__). Without this, goober overwrites the
396 // nonce we set on the pre-created element with undefined, clearing it.
397 ;(window as any).__nonce__ = nonce
398
399 const root = target ?? document.head
400 if (root.querySelector('#_goober')) return
401 const styleTag = document.createElement('style')
402 const textNode = document.createTextNode('')
403 styleTag.appendChild(textNode)
404 styleTag.id = '_goober'
405 styleTag.setAttribute('nonce', nonce)
406 root.appendChild(styleTag)
407}

Callers 3

mountMethod · 0.90
mountMethod · 0.90
utils.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected