diff --git a/components/_util/wave.tsx b/components/_util/wave.tsx
index 38fdd95f1c..4a9e941702 100644
--- a/components/_util/wave.tsx
+++ b/components/_util/wave.tsx
@@ -1,4 +1,5 @@
import * as React from 'react';
+import { updateCSS } from 'rc-util/lib/Dom/dynamicCSS';
import { supportRef, composeRef } from 'rc-util/lib/ref';
import raf from './raf';
import { ConfigConsumer, ConfigConsumerProps, CSPConfig, ConfigContext } from '../config-provider';
@@ -77,7 +78,6 @@ export default class Wave extends React.Component<{ insertExtraNode?: boolean }>
const attributeName = this.getAttributeName();
node.setAttribute(attributeName, 'true');
// Not white or transparent or grey
- styleForPseudo = styleForPseudo || document.createElement('style');
if (
waveColor &&
waveColor !== '#ffffff' &&
@@ -86,21 +86,18 @@ export default class Wave extends React.Component<{ insertExtraNode?: boolean }>
!/rgba\((?:\d*, ){3}0\)/.test(waveColor) && // any transparent rgba color
waveColor !== 'transparent'
) {
- // Add nonce if CSP exist
- if (this.csp && this.csp.nonce) {
- styleForPseudo.nonce = this.csp.nonce;
- }
-
extraNode.style.borderColor = waveColor;
- styleForPseudo.innerHTML = `
+
+ styleForPseudo = updateCSS(
+ `
[${getPrefixCls('')}-click-animating-without-extra-node='true']::after, .${getPrefixCls(
- '',
- )}-click-animating-node {
+ '',
+ )}-click-animating-node {
--antd-wave-shadow-color: ${waveColor};
- }`;
- if (!node.ownerDocument.body.contains(styleForPseudo)) {
- node.ownerDocument.body.appendChild(styleForPseudo);
- }
+ }`,
+ 'antd-wave',
+ { csp: this.csp },
+ );
}
if (insertExtraNode) {
node.appendChild(extraNode);
diff --git a/components/config-provider/__tests__/icon.test.js b/components/config-provider/__tests__/icon.test.js
new file mode 100644
index 0000000000..5cc87f5ad4
--- /dev/null
+++ b/components/config-provider/__tests__/icon.test.js
@@ -0,0 +1,53 @@
+import React from 'react';
+import { mount } from 'enzyme';
+import { SmileOutlined } from '@ant-design/icons';
+import IconContext from '@ant-design/icons/lib/components/Context';
+import ConfigProvider from '..';
+
+describe('ConfigProvider.Icon', () => {
+ beforeEach(() => {
+ // eslint-disable-next-line jest/no-standalone-expect
+ expect(document.querySelectorAll('style')).toHaveLength(0);
+ });
+
+ afterEach(() => {
+ document.querySelectorAll('style').forEach(style => {
+ style.parentNode.removeChild(style);
+ });
+ });
+
+ it('basic', () => {
+ const wrapper = mount(
+