Skip to content

Commit 4721c48

Browse files
crisbetoAndrewKushnir
authored andcommitted
fix(core): error if document body is null (#49818)
Fixes an error that came up internally which was being thrown, because in some cases the `document.body` might be null. PR Close #49818
1 parent 61f63cf commit 4721c48

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/core/src/application_tokens.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export const CSP_NONCE = new InjectionToken<string|null>('CSP nonce', {
109109
// 4. Have the `ComponentFactory` read the attribute and provide it to the injector under the
110110
// hood - has the same problem as #1 and #2 in that the renderer is used to query for the root
111111
// node and the nonce value needs to be available when the renderer is created.
112-
return getDocument().body.querySelector('[ngCspNonce]')?.getAttribute('ngCspNonce') || null;
112+
return getDocument().body?.querySelector('[ngCspNonce]')?.getAttribute('ngCspNonce') || null;
113113
},
114114
});
115115

0 commit comments

Comments
 (0)