mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00
refactor: Remove unnecessary div containers (#31492)
This commit is contained in:
parent
47d480b58f
commit
9166e9940b
@ -27,16 +27,12 @@ export type ModalFunc = (props: ModalFuncProps) => {
|
|||||||
export type ModalStaticFunctions = Record<NonNullable<ModalFuncProps['type']>, ModalFunc>;
|
export type ModalStaticFunctions = Record<NonNullable<ModalFuncProps['type']>, ModalFunc>;
|
||||||
|
|
||||||
export default function confirm(config: ModalFuncProps) {
|
export default function confirm(config: ModalFuncProps) {
|
||||||
const div = document.createElement('div');
|
const container = document.createDocumentFragment();
|
||||||
document.body.appendChild(div);
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||||
let currentConfig = { ...config, close, visible: true } as any;
|
let currentConfig = { ...config, close, visible: true } as any;
|
||||||
|
|
||||||
function destroy(...args: any[]) {
|
function destroy(...args: any[]) {
|
||||||
const unmountResult = ReactDOM.unmountComponentAtNode(div);
|
ReactDOM.unmountComponentAtNode(container);
|
||||||
if (unmountResult && div.parentNode) {
|
|
||||||
div.parentNode.removeChild(div);
|
|
||||||
}
|
|
||||||
const triggerCancel = args.some(param => param && param.triggerCancel);
|
const triggerCancel = args.some(param => param && param.triggerCancel);
|
||||||
if (config.onCancel && triggerCancel) {
|
if (config.onCancel && triggerCancel) {
|
||||||
config.onCancel(...args);
|
config.onCancel(...args);
|
||||||
@ -74,7 +70,7 @@ export default function confirm(config: ModalFuncProps) {
|
|||||||
okText={okText || (props.okCancel ? runtimeLocale.okText : runtimeLocale.justOkText)}
|
okText={okText || (props.okCancel ? runtimeLocale.okText : runtimeLocale.justOkText)}
|
||||||
cancelText={cancelText || runtimeLocale.cancelText}
|
cancelText={cancelText || runtimeLocale.cancelText}
|
||||||
/>,
|
/>,
|
||||||
div,
|
container,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user