Skip to content

Commit

Permalink
Fix primefaces#2423: CSP allow setting inline nonce with PrimeReact.i…
Browse files Browse the repository at this point in the history
…nlineCssNonce
  • Loading branch information
melloware committed Dec 15, 2021
1 parent 124a57a commit 2d6c305
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions components/lib/api/Api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface FilterMatchModeOptions {
interface APIOptions {
ripple?: boolean;
inputStyle?: InputStyleType;
inlineCssNonce?: string;
locale?: string;
appendTo?: AppendToType;
cssTransition?: boolean;
Expand Down
2 changes: 2 additions & 0 deletions components/lib/api/PrimeReact.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export default class PrimeReact {

static autoZIndex = true;

static inlineCssNonce = null;

static zIndex = {
modal: 1100,
overlay: 1000,
Expand Down
4 changes: 3 additions & 1 deletion components/lib/utils/DomHandler.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import PrimeReact from '../api/Api';

export default class DomHandler {

static innerWidth(el) {
Expand Down Expand Up @@ -878,7 +880,7 @@ export default class DomHandler {
*/
static createInlineStyle() {
let styleElement = document.createElement('style');
let nonce = process.env.REACT_APP_CSS_NONCE;
let nonce = process.env.REACT_APP_CSS_NONCE || PrimeReact.inlineCssNonce;
if (nonce) {
styleElement.setAttribute('nonce', nonce);
}
Expand Down

0 comments on commit 2d6c305

Please sign in to comment.