Skip to content

injectCSS method not attaching csp nonce passed to it. it is used in antd components internally #671

@skchawala

Description

@skchawala

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch rc-util@5.44.4 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/rc-util/es/Dom/dynamicCSS.js b/node_modules/rc-util/es/Dom/dynamicCSS.js
index 8ddec00..9e5efee 100644
--- a/node_modules/rc-util/es/Dom/dynamicCSS.js
+++ b/node_modules/rc-util/es/Dom/dynamicCSS.js
@@ -52,7 +52,8 @@ export function injectCSS(css) {
     styleNode.setAttribute(APPEND_PRIORITY, "".concat(priority));
   }
   if (csp !== null && csp !== void 0 && csp.nonce) {
-    styleNode.nonce = csp === null || csp === void 0 ? void 0 : csp.nonce;
+    styleNode.setAttribute('nonce', csp.nonce);
+   // styleNode.nonce = csp === null || csp === void 0 ? void 0 : csp.nonce;
   }
   styleNode.innerHTML = css;
   var container = getContainer(option);
diff --git a/node_modules/rc-util/lib/Dom/dynamicCSS.js b/node_modules/rc-util/lib/Dom/dynamicCSS.js
index 95a5191..be33605 100644
--- a/node_modules/rc-util/lib/Dom/dynamicCSS.js
+++ b/node_modules/rc-util/lib/Dom/dynamicCSS.js
@@ -62,7 +62,8 @@ function injectCSS(css) {
     styleNode.setAttribute(APPEND_PRIORITY, "".concat(priority));
   }
   if (csp !== null && csp !== void 0 && csp.nonce) {
-    styleNode.nonce = csp === null || csp === void 0 ? void 0 : csp.nonce;
+    styleNode.setAttribute('nonce', csp.nonce);
+    // styleNode.nonce = csp === null || csp === void 0 ? void 0 : csp.nonce;
   }
   styleNode.innerHTML = css;
   var container = getContainer(option);

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions