mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 11:08:45 +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 default function confirm(config: ModalFuncProps) {
|
||||
const div = document.createElement('div');
|
||||
document.body.appendChild(div);
|
||||
const container = document.createDocumentFragment();
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
let currentConfig = { ...config, close, visible: true } as any;
|
||||
|
||||
function destroy(...args: any[]) {
|
||||
const unmountResult = ReactDOM.unmountComponentAtNode(div);
|
||||
if (unmountResult && div.parentNode) {
|
||||
div.parentNode.removeChild(div);
|
||||
}
|
||||
ReactDOM.unmountComponentAtNode(container);
|
||||
const triggerCancel = args.some(param => param && param.triggerCancel);
|
||||
if (config.onCancel && triggerCancel) {
|
||||
config.onCancel(...args);
|
||||
@ -74,7 +70,7 @@ export default function confirm(config: ModalFuncProps) {
|
||||
okText={okText || (props.okCancel ? runtimeLocale.okText : runtimeLocale.justOkText)}
|
||||
cancelText={cancelText || runtimeLocale.cancelText}
|
||||
/>,
|
||||
div,
|
||||
container,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user