MCPcopy Create free account
hub / github.com/adobe/react-spectrum / getNonce

Function getNonce

packages/react-aria/src/utils/getNonce.ts:37–59  ·  view source on GitHub ↗
(doc?: Document)

Source from the content-addressed store, hash-verified

35 * Security Policy.
36 */
37export function getNonce(doc?: Document): string | undefined {
38 let d = doc ?? (typeof document !== 'undefined' ? document : undefined);
39 if (!d) {
40 return getWebpackNonce(d);
41 }
42
43 if (nonceCache.has(d)) {
44 return nonceCache.get(d);
45 }
46
47 let meta = d.querySelector('meta[property="csp-nonce"]');
48 let nonce =
49 (meta &&
50 meta instanceof getOwnerWindow(meta).HTMLMetaElement &&
51 (meta.nonce || meta.content)) ||
52 getWebpackNonce(d) ||
53 undefined;
54
55 if (nonce !== undefined) {
56 nonceCache.set(d, nonce);
57 }
58 return nonce;
59}

Callers 3

getNonce.test.jsFile · 0.90
usePressFunction · 0.90

Calls 4

getOwnerWindowFunction · 0.90
getWebpackNonceFunction · 0.85
hasMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected