浏览代码

fix: optimize code

代强 2 年之前
父节点
当前提交
dc6f3f7fee
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      packages/semi-ui/_portal/index.tsx

+ 1 - 1
packages/semi-ui/_portal/index.tsx

@@ -55,7 +55,7 @@ class Portal extends PureComponent<PortalProps, PortalState> {
     initContainer = (context: ContextValue, catchError = false) => {
     initContainer = (context: ContextValue, catchError = false) => {
         try {
         try {
             let container: HTMLElement | undefined = undefined;
             let container: HTMLElement | undefined = undefined;
-            if (!this.state?.container || !this.el || !Array.from(this.state.container.childNodes).includes(this.el)) {
+            if (!this.el || !this.state?.container || !Array.from(this.state.container.childNodes).includes(this.el)) {
                 this.el = document.createElement('div');
                 this.el = document.createElement('div');
                 const getContainer = this.props.getPopupContainer || context.getPopupContainer || defaultGetContainer;
                 const getContainer = this.props.getPopupContainer || context.getPopupContainer || defaultGetContainer;
                 const portalContainer = getContainer();
                 const portalContainer = getContainer();