@@ -9,6 +9,7 @@ import type { IDrawerChildProps } from './IDrawerPropTypes';
9
9
import {
10
10
addEventListener ,
11
11
dataToArray ,
12
+ getParent ,
12
13
getTouchParentScroll ,
13
14
isNumeric ,
14
15
removeEventListener ,
@@ -96,7 +97,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
96
97
this . passive = passiveSupported ? { passive : false } : false ;
97
98
}
98
99
const { open, getContainer, showMask, autoFocus } = this . props ;
99
- const container = getContainer && getContainer ( ) ;
100
+ const container = getParent ( getContainer ) ;
100
101
this . drawerId = `drawer_id_${ Number (
101
102
( Date . now ( ) + Math . random ( ) )
102
103
. toString ( )
@@ -123,7 +124,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
123
124
public componentDidUpdate ( prevProps : IDrawerChildProps ) {
124
125
const { open, getContainer, scrollLocker, showMask, autoFocus } =
125
126
this . props ;
126
- const container = getContainer && getContainer ( ) ;
127
+ const container = getParent ( getContainer ) ;
127
128
if ( open !== prevProps . open ) {
128
129
if ( container && container . parentNode === document . body ) {
129
130
currentDrawer [ this . drawerId ] = ! ! open ;
@@ -296,7 +297,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
296
297
297
298
private toggleScrollingToDrawerAndBody = ( right : number ) => {
298
299
const { getContainer, showMask, open } = this . props ;
299
- const container = getContainer && getContainer ( ) ;
300
+ const container = getParent ( getContainer ) ;
300
301
// 处理 body 滚动
301
302
if ( container && container . parentNode === document . body && showMask ) {
302
303
const eventArray = [ 'touchstart' ] ;
@@ -428,7 +429,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
428
429
if ( windowIsUndefined ) {
429
430
return ;
430
431
}
431
- const container = getContainer && getContainer ( ) ;
432
+ const container = getParent ( getContainer ) ;
432
433
const parent = container ? ( container . parentNode as HTMLElement ) : null ;
433
434
this . levelDom = [ ] ;
434
435
if ( level === 'all' ) {
0 commit comments