UNPKG

1.61 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
5var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
6
7Object.defineProperty(exports, "__esModule", {
8 value: true
9});
10exports.default = void 0;
11
12var React = _interopRequireWildcard(require("react"));
13
14var _PortalWrapper = _interopRequireDefault(require("rc-util/lib/PortalWrapper"));
15
16var _Dialog = _interopRequireDefault(require("./Dialog"));
17
18// fix issue #10656
19
20/*
21 * getContainer remarks
22 * Custom container should not be return, because in the Portal component, it will remove the
23 * return container element here, if the custom container is the only child of it's component,
24 * like issue #10656, It will has a conflict with removeChild method in react-dom.
25 * So here should add a child (div element) to custom container.
26 * */
27var DialogWrap = function DialogWrap(props) {
28 var visible = props.visible,
29 getContainer = props.getContainer,
30 forceRender = props.forceRender; // 渲染在当前 dom 里;
31
32 if (getContainer === false) {
33 return React.createElement(_Dialog.default, Object.assign({}, props, {
34 getOpenCount: function getOpenCount() {
35 return 2;
36 }
37 }));
38 }
39
40 return React.createElement(_PortalWrapper.default, {
41 visible: visible,
42 forceRender: forceRender,
43 getContainer: getContainer
44 }, function (childProps) {
45 return React.createElement(_Dialog.default, Object.assign({}, props, childProps));
46 });
47};
48
49DialogWrap.displayName = 'Dialog';
50var _default = DialogWrap;
51exports.default = _default;
\No newline at end of file