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

Function setupStyleSheet

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

Source from the content-addressed store, hash-verified

307// Sets up the goober stylesheet
308// Adds a nonce to the style tag if needed
309export const setupStyleSheet = (nonce?: string, target?: ShadowRoot) => {
310 if (!nonce)
311 return // Goober reads window.__nonce__ every time it creates or accesses its style
312 // element (el.nonce = window.__nonce__). Without this, goober overwrites the
313 // nonce we set on the pre-created element with undefined, clearing it.
314 ;(window as any).__nonce__ = nonce
315
316 const root = target ?? document.head
317 if (root.querySelector('#_goober')) return
318 const styleTag = document.createElement('style')
319 const textNode = document.createTextNode('')
320 styleTag.appendChild(textNode)
321 styleTag.id = '_goober'
322 styleTag.setAttribute('nonce', nonce)
323 root.appendChild(styleTag)
324}

Callers 3

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

Calls

no outgoing calls

Tested by

no test coverage detected