Skip to content

Commit 452cde2

Browse files
authored
fix(multiple): set nonce using setAttribute (#28800)
Uses `setAttribute` to set the nonce, instead of DOM property in order to work properly in SSR. Fixes #28780.
1 parent a365559 commit 452cde2

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/cdk-experimental/column-resize/resize-strategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export class CdkFlexTableResizeStrategy extends ResizeStrategy implements OnDest
238238
this._styleElement = this._document.createElement('style');
239239

240240
if (this._nonce) {
241-
this._styleElement.nonce = this._nonce;
241+
this._styleElement.setAttribute('nonce', this._nonce);
242242
}
243243

244244
this._styleElement.appendChild(this._document.createTextNode(''));

src/cdk-experimental/table-scroll-container/table-scroll-container.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export class CdkTableScrollContainer implements StickyPositioningListener, OnDes
118118
this._styleElement = this._document.createElement('style');
119119

120120
if (this._nonce) {
121-
this._styleElement.nonce = this._nonce;
121+
this._styleElement.setAttribute('nonce', this._nonce);
122122
}
123123

124124
this._styleRoot.appendChild(this._styleElement);

src/cdk/layout/media-matcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function createEmptyStyleRule(query: string, nonce: string | undefined | null) {
6565
mediaQueryStyleNode = document.createElement('style');
6666

6767
if (nonce) {
68-
mediaQueryStyleNode.nonce = nonce;
68+
mediaQueryStyleNode.setAttribute('nonce', nonce);
6969
}
7070

7171
mediaQueryStyleNode.setAttribute('type', 'text/css');

src/youtube-player/youtube-player.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ function loadApi(nonce: string | null): void {
719719
script.async = true;
720720

721721
if (nonce) {
722-
script.nonce = nonce;
722+
script.setAttribute('nonce', nonce);
723723
}
724724

725725
// Set this immediately to true so we don't start loading another script

0 commit comments

Comments
 (0)