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

Function getMetaValue

packages/react-aria/src/utils/getMetaValue.ts:22–49  ·  view source on GitHub ↗
(key: string, doc?: Document)

Source from the content-addressed store, hash-verified

20}
21
22export function getMetaValue(key: string, doc?: Document): string | undefined {
23 let ownerWindow = getOwnerWindow(doc);
24 let ownerDocument = getOwnerDocument(doc);
25
26 if (ownerDocument == null || ownerWindow == null) {
27 return;
28 }
29
30 let content: string | undefined = undefined;
31 let selector = `meta[name="${CSS.escape(key)}"], meta[property="${CSS.escape(key)}"]`;
32 let meta = ownerDocument.querySelector(selector);
33
34 if (meta && meta instanceof ownerWindow.HTMLMetaElement) {
35 if (key === 'csp-nonce' && meta.nonce) {
36 content ??= meta.nonce || undefined;
37 }
38
39 if (meta.content) {
40 content ??= meta.content || undefined;
41 }
42 }
43
44 if (key === 'csp-nonce') {
45 content ??= ownerWindow.__webpack_nonce__ || globalThis.__webpack_nonce__ || undefined;
46 }
47
48 return content;
49}

Callers 2

getNonceFunction · 0.90

Calls 2

getOwnerWindowFunction · 0.90
getOwnerDocumentFunction · 0.90

Tested by

no test coverage detected